就一个简单的注册功能 点击提交后报此错误,是配置问题,请各位大侠帮忙找下Unable to instantiate Action, userAction, defined for 'addUser' in namespace '/'userActionjava.lang.ClassNotFoundException: userAction下面是各部分配置JSP <s:form action="addUser" method="post">
<s:textfield name="user.userName"></s:textfield>
<s:password name="user.userPassword"></s:password>
<s:submit></s:submit>
</s:form>Web.xml <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list> <listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</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>
struts.xml
<package name="userInfo" namespace="" extends="struts-default">
<action name="addUser" class="userAction">
<result>/succes.jsp</result>
<result name="input">/index.jsp</result>
</action>
</package>
applicationContext.xml
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="CommonDao" class="Dao.UserInfoDao">
<property name="sessionFactory"
ref="sessionFactory">
</property>
</bean>
<bean id="UserInfoBiz" class="Biz.UserInfoBiz">
<property name="dao"
ref="CommonDao">
</property>
</bean>
<bean id="userAction" class="Action.addUser" scope="prototype">
<property name="biz"
ref="UserInfoBiz">
</property>
</bean>
Hibernate.cfg.xml <hibernate-configuration> <session-factory>
<property name="connection.username">sa</property>
<property name="connection.url">jdbc:sqlserver://localhost:1433;databaseName=User</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="myeclipse.connection.profile">User</property>
<property name="connection.password">123</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<mapping resource="Entity/UserInfo.hbm.xml"></mapping>
</session-factory></hibernate-configuration>
<s:textfield name="user.userName"></s:textfield>
<s:password name="user.userPassword"></s:password>
<s:submit></s:submit>
</s:form>Web.xml <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list> <listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</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>
struts.xml
<package name="userInfo" namespace="" extends="struts-default">
<action name="addUser" class="userAction">
<result>/succes.jsp</result>
<result name="input">/index.jsp</result>
</action>
</package>
applicationContext.xml
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="CommonDao" class="Dao.UserInfoDao">
<property name="sessionFactory"
ref="sessionFactory">
</property>
</bean>
<bean id="UserInfoBiz" class="Biz.UserInfoBiz">
<property name="dao"
ref="CommonDao">
</property>
</bean>
<bean id="userAction" class="Action.addUser" scope="prototype">
<property name="biz"
ref="UserInfoBiz">
</property>
</bean>
Hibernate.cfg.xml <hibernate-configuration> <session-factory>
<property name="connection.username">sa</property>
<property name="connection.url">jdbc:sqlserver://localhost:1433;databaseName=User</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="myeclipse.connection.profile">User</property>
<property name="connection.password">123</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<mapping resource="Entity/UserInfo.hbm.xml"></mapping>
</session-factory></hibernate-configuration>
例:
<bean id="userAction" class="com.test.UserAction" scope="prototype">
2.class的时候类的完整路径是否正确
3.aaa.action(虽然不写可以)
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)
root cause java.lang.ClassNotFoundException: userAction
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
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.FilterDispatcher.doFilter(FilterDispatcher.java:395)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
--------------------------------------------------------------------------------
<bean id="userAction" class="com.test.UserAction" scope="prototype">
就像楼上说的那样,在class="com.test.UserAction"把你的类的完整路径写上去,连包名也要写对