若是前臺將Object對象,使用JSON.stringify(obj)轉成Json字符串,並依此請急求後臺時,其中java
contentType : application/x-www-form-urlencoded ,該屬性爲表單提交的默認類型。
spring
使用Spring Mvc接收參數和Request 接收參數有所不一樣:app
Spring Mvc接收參數: 會對Json字符串中的""進行轉義,而request.getParamter()不會。
url
示例:
code
前臺代碼:orm
var testObj=new Object();
testObj.name='abc';
testObj.age='8';
var testJson=JSON.stringify(testObj);
console.log(conditionsJson);
lrDgLeftGrid.datagrid('load',{
'testJson':testJson
});
對象
後臺代碼:字符串
@RequestMapping(value="/testJson") @ResponseBody public DataGrid testJson(PageHelper ph, String testJson,HttpServletRequest request) throws Exception { System.out.println("spring="+testJson); System.out.println("getParamter="+request.getParameter("testJson")); }
後臺輸出:get
spring={"name":"abc","age":"8"} getParamter={"name":"abc","age":"8"}