您的位置:首页 > 理论基础 > 计算机网络

HTTP Status 500 -Unable to instantiate Action....

2017-10-31 21:28 501 查看
关于无法出示Action的错误(错误提示如下):
HTTP Status 500 -Unable to instantiate Action,
com.demo.registeration.action.UserAction,
defined for 'user' in namespace '/'Failed to convert property value of type [com.demo.registeration.action.UserAction]
to required type [com.demo.registeration.model.User] for property 'u';
nested exception is java.lang.IllegalArgumentException:
Cannot convert value of type [com.demo.registeration.action.UserAction] to required type
[com.demo.registeration.model.User] for property 'u': no matching editors or conversion strategy found

struts2-spring-plugin插件在产生action的时候,会自动把action的属性注入进来,默认按照名字注入。

当action启动后,会自动将里面的属性(提供set方法的属性)自动装载(不写@Resource的也装载,就是@Resource可以不写了),

由于action已经交给了spring容器来管理,如下action的默认名字就是userAction。而此时,如果你的Action中刚好有一个
引用的名字也叫userAction,就可能引起上面的bug
@Component
public class UserAction extends ActionSupport implements ModelDriven{......}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐