实例类多对多映射,ID都是Long
private Set<Role> roles = new HashSet<Role>();
private Set<AdminUser> adminUsers = new HashSet<AdminUser>();
现在问题是复制框保存时出错
<form:checkboxes path="roles" items="${roleList}"
itemValue="id" itemLabel="name"/>
控制层
public String edit(HttpServletRequest request,<span></span> AdminUser adminUser<span></span>)throws Exception {
....
}
接收adminUser adminUser 就报错,好像是类型转换问题,不知如何解决?
接收string[] roles 就不报错。
Field error in object 'adminUser' on field 'roles': rejected value [1,2,3]; codes [typeMismatch.adminUser.roles,typeMismatch.roles,typeMismatch.java.util.Set,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [adminUser.roles,roles]; arguments []; default message [roles]]; default message [Failed to convert property value of type 'java.lang.String[]' to required type 'java.util.Set' for property 'roles'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.szqws.trj.entity.Role] for property 'roles[0]': no matching editors or conversion strategy found]
2015-05-23 09:41:32,578 - DEBUG - Resolving exception from handler [public java.lang.String com.szqws.trj.admin.controller.AdminUserController.edit(javax.servlet.http.HttpServletRequest,com.szqws.trj.entity.AdminUser) throws java.lang.Exception]: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
这是form头部
<form:form method="post" action="adminUser_${adminUser.id == null ? 'add' : 'edit'}.do" commandName="adminUser">
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。