`
xgia7
  • 浏览: 13440 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Cannot invoke setId on bean class 'class ' - argument type mismatch - had object

阅读更多
***********************************************************************************
***********************************************************************************
Struts Problem Report
Struts has detected an unhandled exception:

Messages: argument type mismatch
Cannot invoke com.flyoa.entity.IdEntity.setId on bean class 'class com.flyoa.entity.auth.Role' - argument type mismatch - had objects of type "java.lang.String" but expected signature "java.lang.Integer"

File: org/apache/commons/beanutils/PropertyUtilsBean.java
Line number: 2,181
--------------------------------------------------------------------------------
Stacktraces
java.lang.IllegalArgumentException: Cannot invoke com.flyoa.entity.IdEntity.setId on bean class 'class com.flyoa.entity.auth.Role' - argument type mismatch - had objects of type "java.lang.String" but expected signature "java.lang.Integer"
    org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2181)
    org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2141)
    org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1948)
    org.apache.commons.beanutils.PropertyUtilsBean.setProperty
***********************************************************************************
***********************************************************************************

-----------------------------------------------------------------------------------
首先告诉大家上面调试信息是save提交之后,页面返回的错误信息,解释如下:
堆栈跟踪
非法参数异常:不能调用bean类setId“class Role” - 参数类型不匹配 - 有类型的对象“java.lang.String”,
但预期的签名“java.lang.Integer”
-----------------------------------------------------------------------------------
情况是这样的,之前这个工程的实体类的主键全部是用的uuid.hex,数据库也是varchar类型,
后来为了和另外一个项目方便接口,将数据库中的主键id字段全部修改为bigint类型,实体类
也全部修改为Integer类型,所有java类中的id引用(之前是String类型)全部修改为Integer,
单表的增删改查操作是没有问题的,
------------------------------------------------------------------------------------

上面的操作是“当添加一个用户,同时需要将角色关联到这个当前用户”,出现上面的错误,
个人认为出错原因:应该是返回的页面上的,页面上是String类型,而后台java类已经修改了interger,
但是一直在页面上没有找到这个关注点,

下面是save时form表单提交的数据,提交表单的时候需要将role的id先提交,
估计是提交的角色listKey的id没有转换为Integer,
*************************************************************************************
<s:form action="/auth/user!save.action">
<s:if test="id!=null"><s:hidden name="id" /></s:if>

<s:checkboxlist label="%{getText('user.roles')}" name="checkedRoleIds"
list="getAllRoles()"
listKey="id"
listValue="getRoleName()" />
<s:submit value="%{getText('general.save')}" align="center" />
</s:form>
**************************************************************************************
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics