spring与struts2整合出现错误HTTP Status 500 - Unable to instantiate Action

Posted 一杯96的java

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring与struts2整合出现错误HTTP Status 500 - Unable to instantiate Action相关的知识,希望对你有一定的参考价值。

在进行spring和struts2整合的时候因为大意遇到了一个问题,费了半天神终于找到了问题所在,故分享出来望广大博友引以为戒!!

我们都知道在spring和struts2整合时,spring接管了action对象的创建,所以一定要在spring配置文件中配置action,这里需要注意的是配置<bean id="???">中的id时,

要与struts.xml配置action中的<action class="???">class一致,否则就会出现如下问题:

 

楼主就是因为把struts.xml配置action中的class写成了action类路径,导致了这个问题,所以亲们一定要注意!

错误配置代码:applicationContext.xml中<bean id="cartAction" class="com.ansibee.shop.web.action.CartAction" scope="prototype">

       struts.xml中<action name="cart_*" class="com.ansibee.shop.web.action.CartAction" method="{1}">

 

正确配置代码:applicationContext.xml中<bean id="cartAction" class="com.ansibee.shop.web.action.CartAction" scope="prototype">

       struts.xml中<action name="cart_*" class="cartAction" method="{1}">

以上是关于spring与struts2整合出现错误HTTP Status 500 - Unable to instantiate Action的主要内容,如果未能解决你的问题,请参考以下文章

Spring 整合hibernate与struts2的核心文件

struts2与spring整合问题,访问struts2链接时,spring会负责创建Action

改用Struts2.5 出现404 错误

Struts2与Spring整合

Struts2与Spring整合

ssh整合思想 Spring与Hibernate和Struts2的action整合 调用action添加数据库 使用HibernateTemplate的save(entity)方法