http://sys-ks-cnm.iteye.com/blog/1884623
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.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
root cause
java.lang.ClassNotFoundException: LoginAction
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:96)
com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:212)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:132)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:109)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:288)
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.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
配置如下:
applicationcontext.xml
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/spring/application.properties</value>
</list>
</property>
</bean>
<import resource="/spring/beans-datasource.xml"/>
<import resource="/spring/beans-dao.xml"/>
<context:component-scan base-package="sshLogin" />
struts.xml
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="false" />
<package name="strutsLogin" namespace="" extends="struts-default">
<action name="Login" class="LoginAction" method="login">
<result name="success" type="redirectAction">List</result>
<result name="input">error.jsp</result>
</action>
<action name="Regist" class="LoginAction" method="regist">
<result name="success" type="redirectAction">List</result>
<result name="show">update.jsp</result>
<result name="input">index.jsp</result>
</action>
<action name="Update" class="LoginAction" method="update">
<result name="success" type="redirectAction">List</result>
<result name="input">index.jsp</result>
</action>
<action name="Query" class="LoginAction" method="query">
<result name="success">update.jsp</result>
</action>
<action name="Delete" class="LoginAction" method="delete">
<result name="success" type="redirectAction">List</result>
<result name="input" type="redirectAction">List</result>
</action>
</package>
<package name="strutsList" namespace="" extends="struts-default">
<action name="List" class="LoginAction" method="list">
<result name="success">list.jsp</result>
<result name="input">index.jsp</result>
</action>
</package>
</struts>
web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
java 代码
@Controller("LoginAction")
@Scope("prototype")
public class LoginAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
User user ;
@Autowired
LoginService loginService;
List<User> list =null;
/**
麻烦各位看下原因 是不是action没被spring托管