日期:2014-05-17  浏览次数:20812 次

关于spring整合Struts2
Unable to instantiate Action, loginAction, defined for 'login' in namespace '/'loginAction
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:307)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:388)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:187)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)


struts.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE struts PUBLIC 
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<constant name="struts.objectFactory" value="spring" />
<package name="struts2" extends="struts-default">
<action name="login" class="loginAction">
<result name="success" type="redirect">/jsp/main.jsp</result>
<result name="error">/index.jsp</result>
</action>
</package>
</struts>
applicationContext.xml文件
<bean id="loginAction" class="com.zd.permission.ado.impl.LoginAction">
<property name="loginAccess" ref="loginAccess" />
</bean>

<bean id="loginAccess" class="com.zd.permission.ado.impl.LoginAccessImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

jsp页面
<s:form id="form" action="login">

------解决方案--------------------
一看就是配置出错了,loginAction那好好检查下】

------解决方案--------------------
命名空间 "/" 下 找不到 login
建议在<package>下配置参数 namespace 试试

------解决方案--------------------
你的action写的肯定有问题百度下Unable to instantiate Action,很多的
------解决方案--------------------
配置有问题。。好好检查检查loginAction地方。。
------解决方案--------------------
1.不知道楼主有没有写Spring的监听器在web.xml中
2.不知道喽主是不是Struts2是配置过滤器是/*还是/do还是/*action
楼主好好检查吧,这个我看是没有问题的,控制反转就是这么个意思
------解决方案--------------------
<package name="struts2" extends="struts-default">

<package name="struts2" extends="struts-default" namespace="/">
是不是这样?
------解决方案--------------------
要加命名空间啊 namespace
------解决方案--------------------
要加命名空间啊 namespace