spring 页面跳转不到对应的Controller方法
来源:互联网 发布:儿童注意力训练软件 编辑:程序博客网 时间:2024/05/21 10:09
错误:如标题
问题描述:
<div class="control-group"><label for="resOpsList" class="control-label">对资源的操作:</label><div class="controls"><c:forEach items="${resOpMap}" var="map"><c:out value="${map.key}" /><br><c:forEach items="${map.value}" var="resOp"><input type="checkbox" name="resOps" value="${resOp.id}" <c:if test="${resOp.isSelect==1}">checked="true"</c:if>/><c:out value="${resOp.op.name}" /></c:forEach><br><br></c:forEach></div></div>
点击提交时无法跳转到下面的Controller方法:
/** * 给角色分配资源操作 * * @return */@RequestMapping(value = "addResAndOp", method = RequestMethod.POST)public String addResAndOp(@Valid @ModelAttribute("role") Role role,/** * 给角色分配资源操作 * * @return */@RequestMapping(value = "addResAndOp", method = RequestMethod.POST)public String addResAndOp(@Valid @ModelAttribute("role") Role role,@RequestParam(value = "resOps") List<Long> selectIds,RedirectAttributes redirectAttributes) {role.getResOpList().clear();for (Long id : selectIds) {role.getResOpList().add(new ResourceOp(id));}roleService.addRole(role);return "redirect:/admin/role";} List<Long> selectIds,RedirectAttributes redirectAttributes) {role.getResOpList().clear();for (Long id : selectIds) {role.getResOpList().add(new ResourceOp(id));}roleService.addRole(role);return "redirect:/admin/role";}
原因:jsp中checkBox属性name的值原本为resOPList,下面方法的
@RequestParam(value = "resOps")的resOp原本为resOpList,
错误信息是:Field error in object 'role' on field 'resOpList': rejected value [8,9,10]; codes [typeMismatch.role.resOpList,typeMismatch.resOpList,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [role.resOpList,resOpList]; arguments []; default message [resOpList]]; defaul........
解决方法是把resOpList改为一个另外的名称。
0 0
- spring 页面跳转不到对应的Controller方法
- 写的代码不报错,但跳转不到对应的控制层,反而跳转到登陆页面
- spring boot 扫描不到自定义的Controller。。。
- spring mvc controller 跳转 到另一个controller 方法
- WEB开发中遇到的困难,controller方法对应的url显示不出来页面
- spring mvc controller 获取不到@Value处理方法
- 记录一个Spring MVC Controller层,跳转到前端页面以及返回参数的包装类
- 通用页面跳转Controller
- controller控制页面跳转
- Spring MVC使用@ResponseBody无法跳转到对应的jsp页面以及ie8下报错的解决方法
- 如何一启动web程序,直接访问某个controller里的方法进而跳转页面
- spring MVC controller 跳转
- spring mvc controller跳转
- 页面跳转的方法
- 页面跳转的方法
- 页面跳转的方法
- ionic3三种跳转方法对应的页面间数据传递及Events
- iOS-关于页面跳转时全局变量赋值不到的问题
- 怎样查看手机里记住的WIFI隐藏密码
- SQL 小结
- enable_shared_from_this
- 后台读取绑定控件中的TextBox值
- Linux下Tomcat重新启动
- spring 页面跳转不到对应的Controller方法
- Eclipse快捷键 10个最有用的快捷键
- 解析 Java 类和对象的初始化过程
- 调用存储过程
- Perl字符串处理
- 从Delphi开始学Cocos2dx-3.0[11]:持续动作之组合动作
- 多表关联视图
- 清空的回收站还可以恢复文件吗
- 基于嵌入式Linux与S3C2410平台的图像识别与处理