SpringMVC传递multiple类型select后台Controller的接收方法
Spring MVC在接收集合请求参数时,需要在Controller方法的集合参数里前添加@RequestBody,而@RequestBody默认接收的enctype (MIME编码)是application/json
https://blog.csdn.net/howroad/article/details/80324300
https://blog.csdn.net/lutinghuan/article/details/46820023
http://jxd-zxf.iteye.com/blog/2072300/
$("#submit").click(function(){ var sitename = ""; $("#selectSite option:selected").each(function(){ sitename+=$(this).text()+","; }); if(sitename.lastIndexOf(',') >0) sitename = sitename.substring(0, sitename.length - 1); // alert($("#confForm").serialize()); $.ajax({ type:"post", url:"/smcnew/conf/add", dataType:"json", data:{ "name":$("#name").val(), "site.uri":$("#selectSite").val()+"", "site.name":sitename, }, success:function(data){ } }); });
springMVC接收:
@RequestMapping("/add") public void addConf(ConferenceInfo infoEx,@RequestParam("site.uri")List<String> siteuri, @RequestParam("site.name")List<String> sitename){ System.out.println(infoEx.getBeginTime()+infoEx.getName()); }