新手求助,ssh2框架找不到action的问题

vitottre 2017-05-06 10:31:25
这是报错Unable to instantiate Action, UserTypeAction, defined for 'userType_list' in namespace '/'UserTypeAction

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.devMode" value="true" />
<!-- 把扩展名配置为action -->
<constant name="stuts.action.extension" value="action"/>
<!-- 把主题配置为simple -->
<constant name="struts.ui.theme" value="simple"/>


<package name="default" namespace="/" extends="struts-default">
<!-- 测试用用得action 还没与spring整合,class写类的全限定名 -->
<!-- 在整合spring后可以写bean的名称 -->
<action name="test" class="testAction">
<result name="success">/test.jsp</result>
</action>

<!-- 用户类型管理 -->
<action name="userType_*" class="UserTypeAction" method="{1}">
<result name="list">/WEB-INF/jsp/UserTypeAction/list.jsp</result>
<result name="addUI">/WEB-INF/jsp/UserTypeAction/addUI.jsp</result>
<result name="editUI">/WEB-INF/jsp/UserTypeAction/editUI.jsp</result>
<result name="tolist" type="redirectAction">userType_list</result>
</action>
</package>

<!-- Add packages here -->

</struts>



applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Middle tier application context definition for the image database.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<!-- 自动扫描装配bean对象,包名 -->
<context:component-scan base-package="com.community.mis"></context:component-scan>

<!-- 整合hibernate和spring。。配置一个sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 指定hibernate的配置文件 -->
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
<!-- 配置c3p0的连接池 通过反射调用默认方法-->
<property name="dataSource" >
<bean class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="jdbc:sqlserver://localhost:1433;DatabaseName=community"></property>
<property name="driverClass" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"></property>
<property name="user" value="sa"></property>
<property name="password" value="123456"></property>
<!-- 连接池 其他配置 -->
<property name="initialPoolSize" value="3"></property>
<property name="minPoolSize" value="3"></property>
<property name="maxPoolSize" value="5"></property>
<property name="acquireIncrement" value="3"></property>
<property name="maxStatements" value="8"></property>
<property name="maxStatementsPerConnection" value="5"></property>
<property name="maxIdleTime" value="1800"></property>
</bean>
</property>
</bean>
<!-- 配置生命事务管理(采用注解的方式) -->
<!--事务管理器-->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- tx的注解驱动 -->
<tx:annotation-driven transaction-manager="txManager"/>


</beans>



web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置spring的用于初始化容器对象的监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>


<!-- 配置Struts核心的过滤器 -->
<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>


<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>


</web-app>


struts.xml和applicationComtext.xml在scr下建的config包里,web.xml在web-inf下百度了半天找不到问题在哪里。求大神教下!!
...全文
440 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
大橘子呀 2017-05-07
  • 打赏
  • 举报
回复
<result name="tolist" type="redirectAction">userType_list</result>	
你这个没加.action 是不是
vitottre 2017-05-06
  • 打赏
  • 举报
回复
package com.community.mis.action; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import com.opensymphony.xwork2.ActionSupport; @Controller @Scope("prtototype")//保证多例 public class UserTypeAction extends ActionSupport { public String list() throws Exception{ return "list"; } public String delete() throws Exception{ return "toList"; } /*添加页面*/ public String addUI() throws Exception{ return "addUI"; } /*添加*/ public String add() throws Exception{ return "toList"; } public String editUI() throws Exception{ return "editUI"; } public String edit() throws Exception{ return "toList"; } }

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧