js 对象 该阵列看起来像 我明白http://blog.csdn.net/baicp3/article/details/12752255本文
我们指示样品棒
data3一个js对象。遗嘱java当代码被接收到一个entity 跟js对象里面的字段相应上。
var data3 = {"sign" : "0","remarks" : "ddddd","firstKey" : "1","firstValue" : "1","eachKey" : "1","eachValue" : "1"} ;$.ajax({url : '../freight/creatfreight.html',type : "POST",dataType : "json",contentType : 'application/json;charset=UTF-8',data : JSON.stringify(data3), //转换为json字符串 假设不转,java代码中是获取不到值success : function(data) {alert("ccc");},error : function(e) {alert("err");}});
我们看java代码
@RequestMapping(value = "/creatfreight")public @ResponseBody String creatFreightTempl(@RequestBody FreightDetailEntity fd,HttpServletRequest request,Model model) throws Exception {
//这里的重点是@RequestBody这个注解,本人在之前的开发中非常少接触到 }
这样js中的对象的值。就行传到 FreightDetailEntity 这个entity中了。
2.我们来看sprngmvc接收 js中的数组对象。
看例如以下图就明确了。
应该看图就能看明确怎样接收js中的数组对象。
3.多个变量共用springmvc中controller中的一个方法。
@RequestMapping(value = "/{groupCode}", method = RequestMethod.GET)public String view(Model model,@PathVariable("groupCode") String groupCode) {model.addAttribute("groupCode", groupCode);return "";}
版权声明:本文博客原创文章,博客,未经同意,不得转载。
转载于:https://www.cnblogs.com/bhlsheji/p/4652133.html