struts+spring+MyEclipse 找不到Action类

MainRed 2011-09-22 06:35:27
用struts spring整合说找不到Action类,
struts.xml
<package name="default" namespace="/" extends="struts-default">
<action name="add" class="userAction" method="add">
<result type="redirectAction">
<param name="actionName">list</param>
</result>
</action>
</package>
appliactionContext.xml
<bean id="userAction" class="com.swart.action.UserAction">
<property name="student">
<ref bean="studentUser"/>
</property>
</bean>
但把class换成完整路就没问题了,包应该加够了。
...全文
183 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
芒果先生 2012-06-21
  • 打赏
  • 举报
回复
应该是加少了个sturts-spring-plugin.jar包吧,我也是经常遇到这个问题
MainRed 2011-10-09
  • 打赏
  • 举报
回复
这是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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/src/applicationContext.xml</param-value>
</context-param>
-->
<!-- 用来定位Spring XML文件的上下文配置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<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></web-app>
这个是applicationContext.xml的内容:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/ssh"></property>
<property name="username" value="root"></property>
<property name="password" value="12345"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list><value>com/swart/entity/user.hbm.xml</value></list>
</property>
</bean>
<bean id="userDao" class="com.swart.dao.impl.UserDaoImpl">
<property name="sessionFactory">
<ref bean ="sessionFactory"/>
</property>
</bean>
<bean id="studentUser" class="com.swart.bussiness.impl.StudentUserImpl">
<property name="dao">
<ref bean = "userDao"/>
</property>
</bean>
<bean id="userAction" class="com.swart.action.UserAction">
<property name="student">
<ref bean="studentUser"/>
</property>
</bean>
<!-- 配置事务管理 -->
<!-- 配置事务管理器,将事务交给Spring管理 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</beans>
MainRed 2011-10-09
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zhangyanling871218 的回复:]

1、你的web.xml中有这个配置吗?
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2、还有struts.xml中加一句配置试试:<controller processorClass="org.springfr……
[/Quote]

第一个加了,第二个我配置的常量
<constant name="struts.objectFactory" value="spring"/>
第三个也写了。
zf_881012 2011-09-23
  • 打赏
  • 举报
回复
整合配置问题
kangchongmian 2011-09-23
  • 打赏
  • 举报
回复
1、你的web.xml中有这个配置吗?
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2、还有struts.xml中加一句配置试试:<controller processorClass="org.springframework.web.struts.DeleGatingRequestProcessor" />
3、appliactionContext.xml里加一个属性:
<bean id="userAction" class="com.swart.action.UserAction" scope="prototype">
  • 打赏
  • 举报
回复
class换成完整路就没问题了
是spring里的配置出问题了,要么二个框架没整合
wzl30755 2011-09-23
  • 打赏
  • 举报
回复
要是配置 了什么的都对的话
看看是不是更新过jdk啊 有的时候编译环境不一样了也会找不到action的
MainRed 2011-09-22
  • 打赏
  • 举报
回复
<constant name="struts.objectFactory" value="spring"/>
这句我也加上了
还有MyElipse里的Struts2 Spring Libraries也有。
MainRed 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xiaoqiuwyh 的回复:]
namespace="/" 先去掉试试。
[/Quote]

这个没关系啊,我试了也不行。
xiaoqiuwyh 2011-09-22
  • 打赏
  • 举报
回复
namespace="/" 先去掉试试。
MainRed 2011-09-22
  • 打赏
  • 举报
回复
新手上路,请多帮忙啊。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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