首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

S2SH配置有关问题!

2012-09-22 
S2SH配置问题!!!就一个简单的注册功能 点击提交后报此错误,是配置问题,请各位大侠帮忙找下。。。Unable to in

S2SH配置问题!!!
就一个简单的注册功能 点击提交后报此错误,是配置问题,请各位大侠帮忙找下。。。

Unable to instantiate Action, userAction, defined for 'addUser' in namespace '/'userAction

java.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>

[解决办法]
<bean id="userAction" class="Action.addUser" scope="prototype">



是不是写错了啊
[解决办法]
strutx.xml中 把 这个namespace="" 去掉

使用默认命名空间即可

因为框架没有在指定的空间中找到action,则会去“/” 下找 ,再没有,则报告这个错误

表单中的action地址 应该是 namespace和action名的组合
[解决办法]
class应该写UserAction全路径
例:
<bean id="userAction" class="com.test.UserAction" scope="prototype">
[解决办法]
1.namespace去掉或者赋值
2.class的时候类的完整路径是否正确
3.aaa.action(虽然不写可以)
[解决办法]
先把struts的问题解决,如果struts还没熟悉,就先不要加hibernate等其他框架。
[解决办法]

探讨
class应该写UserAction全路径
例:
<bean id="userAction" class="com.test.UserAction" scope="prototype">

[解决办法]
包路径不对
[解决办法]
java.lang.ClassNotFoundException: userAction

说明你这个配置文件中指定的这个类的路径不对,找不到这个类
<bean id="userAction" class="com.test.UserAction" scope="prototype">
就像楼上说的那样,在class="com.test.UserAction"把你的类的完整路径写上去,连包名也要写对

热点排行