废话不多说直接上代码
jsp:
var orderJson = {
"uName":"123",
"oInDateBegin":"qwe"
};
$.ajax({
type: "post",
url:"${pageContext.request.contextPath}/***/***.do",
contentType:"application/json",
async:"true",
dataType:"json",
data:JSON.stringify(orderJson),
success:function(data){
}
});
java-controller
import:
import net.sf.json.JSONObject;
方法:
@RequestMapping("/text.do")
@ResponseBody
public void text(@RequestBody String orderJson) {
JSONObject fromObject = JSONObject.fromObject(orderJson);
System.out.println(fromObject.get("uName"));
}
搞定