# springMvc **Repository Path**: hson08/springMvc ## Basic Information - **Project Name**: springMvc - **Description**: 单体springMvc技术汇总 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-06-12 - **Last Updated**: 2022-10-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ##Spring接收json字符串参数 参考:https://www.jianshu.com/p/b21555b84c89 这篇文章说得透透的。 ``` $.ajax({ url: "search_data_detail2.action", type: "post", dataType:'json', contentType : 'application/json;charset=utf-8', data: JSON.stringify(obj), success: function (json) { } }); ``` ajax的参数contentType和dataType - contentType主要设置你发送给服务器的格式 - dataType设置你收到服务器数据的格式 contentType:"application/json" :用来告诉服务端消息主体是序列化后的 JSON 字符串。 JSON.stringify() :把js对象转换成json字符串。 @RequestBody :声明springMvc的接收方式。 @2020-06-11 看来@RequestBody是application/json请求的标配