星空网 > 软件开发 > Java

springmvc数组参数传递

在开发中遇到将form中的name值一样的多个input元素传递到后台,我用的是springmvc

刚开始的时候老是报400的请求错误。后来查了下资料,其实解决方案挺简单的。

我的后台controller的代码如下:

 1 @RequestMapping(value = { "/examine" }, produces = "text/html;charset=UTF-8") 2   @ResponseBody 3   public String examine( 4       @RequestParam(value="score") String[] score 5      ) {10     try { //11       System.out.println(score.length);         return JSONUtils.toJSON("0000", "审核成功!");18     } catch (Exception e) {19       e.printStackTrace();20       logger.error("发生了意外?意外信息:" + e.fillInStackTrace());21       return JSONUtils.toJSON("9999", "发生了意外?意外信息:" + e.getMessage());22     }23   }

前台的代码很简单

<form action="examine" method="post">    <input name="score" type="text"/>    <input name="score" type="text"/>    <input name="score" type="text"/>     <input name="score" type="text"/>    <input name="提交" type="submit"/></form>  

 




原标题:springmvc数组参数传递

关键词:Spring

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流