SSH集成错误,请高手解决,HTTP Status 500 - No action instance for path /user could be created

月影传说 2009-04-07 10:37:20
控制台不报错,页面错误如下:

HTTP Status 500 - No action instance for path /user could be created

--------------------------------------------------------------------------------

type Status report

message No action instance for path /user could be created

description The server encountered an internal error (No action instance for path /user could be created) that prevented it from fulfilling this request.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.16





applicationContext.xml文件放在了WEB-INF下,配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://localhost:1433;DatabaseName=zf">
</property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"></ref>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>entity/TblUser.hbm.xml</value>
<value>entity/TUser.hbm.xml</value>
<value>entity/Goods.hbm.xml</value>
<value>entity/Bid.hbm.xml</value></list>
</property>
</bean>


<bean id="userDao" class="dao.impl.UserDaoImpl" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
<property name="sessionFactory">
<ref bean="sessionFactory"></ref>
</property>
</bean>

<bean id="userBiz" class="biz.impl.UserBizImpl" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
<property name="userDao">
<ref bean="userDao"></ref>
</property>
</bean>

<bean name="/user" class="web.action.UserAction" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
<property name="userBiz">
<ref bean="userBiz"></ref>
</property>
</bean></beans>





struts配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
<data-sources />
<form-beans >
<form-bean name="userForm" type="web.form.UserForm" />


</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="userForm"
input="/user.jsp"
name="userForm"
parameter="operate"
path="/user"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="index" path="/index.jsp" />
<forward name="error" path="/error.jsp" />
</action>

</action-mappings>

<message-resources parameter="struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml"/>
</plug-in>
</struts-config>


若将<action
attribute="userForm"
input="/user.jsp"
name="userForm"
parameter="operate"
path="/user"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="index" path="/index.jsp" />
<forward name="error" path="/error.jsp" />
</action>
改为
<action
attribute="userForm"
input="/user.jsp"
name="userForm"
parameter="operate"
path="/user"
scope="request"
type="web.action.UserAction">
<forward name="index" path="/index.jsp" />
<forward name="error" path="/error.jsp" />
</action>

就没有错误,请高手看看到底错在哪里了?
...全文
1645 25 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
ouyangfeng159 2010-11-10
  • 打赏
  • 举报
回复
我也是这个错啊,
∮岁月∮人的行为总是一再重复。因此,卓越不是单一的举动,而是习惯。 主页博客相册|个人档案 |好友 查看文章
HTTP Status 500 - No action instance for path / could be created2009-08-14 08:44自己总结主要有几下原因:

1.action是用spring代理的,而却没有用spring的代理action。

2.action的全路径名和在struts配置文件的action的type类型名字不一样,导致不能创建actiong,这也是最常见的错误,

3.到web.xml,没有把struts加进来

4.由于缺少某个包导致不能通过创建action,这里需要说明的一点是,就算hibernate的配置错误,也可能导致不能创建action。

5.struts的创建实例是需要线程安全的,而在action中的类中,不能有成员变量。

6.版本问题
在开发环境中使用的是struts的高版本,在运行环境中使用的是struts的低版本.
如在开发环境中,使用struts1.1以上版本,编写的Action类继承struts的基类DispatchAction.
但在运行环境中部署的是struts低版本的jar包,也会报这样的错误.
这种情况就是很多人说的在一台电脑上运行没问题,但换成了另一台电脑就出问题了.

7.struts里的action,form,model都没有继承,hibernate配置错。

8。asm-2.2.3.jar冲突
bdqnfang2008 2009-12-01
  • 打赏
  • 举报
回复
就是 action 的 type里写错了。我已经解决啦!
灰哥 2009-09-27
  • 打赏
  • 举报
回复
汗。。你是不是想说你不想改变action的type属性也能正常运行...
其实也又方法。
在你的struts-config.xml文件中加上一个控制器就可以不要每次多更改action的属性了.

<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
上面的代码加在 </action-mappings>后面。
其实他们的功能多是一样的.但你应该弄明白加上之后到底做了什么。。。
为什么要这样做....加油。
hernercrespo 2009-09-25
  • 打赏
  • 举报
回复
我可以肯定你的struts.config.xml配置文件里面的 action 对应的type写错了!
我也遇到过,解决了··
好吃的松子 2009-08-17
  • 打赏
  • 举报
回复
服务器启动时也没有报错信息吗?
pei_zhenxi 2009-08-17
  • 打赏
  • 举报
回复
线程!
thender_00 2009-05-01
  • 打赏
  • 举报
回复
呵呵,我也碰到了一样的问题,SSH搭配应该没有问题.
就是Action找不到,估计还是几个框驾的问题.关注!
dadi5566 2009-04-20
  • 打赏
  • 举报
回复
包冲突的原因
把asm-2.2.3.jar移除了试一下
「已注销」 2009-04-20
  • 打赏
  • 举报
回复
SSH不是很熟
zhangjunlanlan 2009-04-12
  • 打赏
  • 举报
回复
500错误,可能就是你页面有点小小的问题
比如某个单词的少写了个字母等等,在html下是步会报错的,
也很难发现一些小错误,你可以找同事看看,细心的肯能会有所发现
当然也可能是你工具有问题,你是用Eclipse开发?像eclipse本身
就存在很多问题. 错误越难发现,解决错我后你才越有成就感,当然也肯是
你的马虎造成的一点小错误呢.. 能把你的程序拷贝过来吧?
zhangjunlanlan 2009-04-12
  • 打赏
  • 举报
回复
集成代理其实要注意配两个地方
web.xml的配置,以及依赖注入application*.xml的配置
对于那个代理类可以直接用
<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">//不改变action的type属性
</controller>
效果更好,在struts中配置

集成的步骤
1.创建一个webproject,添加一些必须的包来存放文件
2.添加struts框架
.添加jar包 antlr.jar,commons-beanutils.jar,commons-digester.jar,commons-fileupload.jar,commons-logging.jar,
commons-validator.jar,jakarta-oro.jar,struts.jar等八个jar
[.如果一个项目由多个组员完成,组员可以有多个struts-config*.xml文件,需要修改web.xml文件,在web.xml中把xml文件直接用逗号隔开后加入即可]
3.添加spring框架
.选择aop,core,orm/dao/hibernate3,和web,.把jar包拷贝到项目中,选copy
.设置applicationContext.xml的路径[如果,有多个文件,可以在web-inf下建个文件夹,把所有以applicationcontext开头的xml文件全部考贝过去]
.<!-- 配置spring的核心配置文件,表示在工程发布时,读取配置中的信息,激活spring容器,让spring管理类的实例-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 配置spring监听器,当servlet上下创建时,spring将监听,并转换成为spring的context。在DWR应用中也必须
配置监听器 //listener负责读取context-param中配置的contextConfigLocation这个变量得到配置文件,
生成beanfactory , bean,然后放到servletcongtext中-->

.转入第二步配置如下文件
<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
作用是加入spring对struts的托管,
目的是在spring中注入action,得到动态选择actio组件的目的
[如果不配置此文件也可,则必须对action中的type属性配置为org.springframework.web.struts.DelegatingActionProxy代理类,
表明此action交给spring创建配置注入,功效如同以上配置文件一样]
4.添加hibernate框架
参见ssh教程.doc的添加步zou
























servletcongtext中
月影传说 2009-04-12
  • 打赏
  • 举报
回复
楼上各位好心人的意见,以前我也都用过,现在程序中的用法和代码都应该没问题,唯一不能确定的就是jar的冲突,比如集成后的asm-2.2.3.jar有的程序中不删除也没事,有的程序中不删除就要抱错,到底哪些包可能会造成冲突,很不好确定,我怀疑这个错误,也有可能和jar包冲突有关,有时间再看看吧
liup19751227 2009-04-08
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 yinyuan1987 的回复:]
你贴出来的代码没有什么错误

你既然使用Spring的Action代理
<bean name="/user" class="web.action.UserAction" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
<property name="userBiz">
<ref bean="userBiz"> </ref>
</property>
</bean>

就要把你的 Action中定义的属性增加setXXX()方法,
这样做的目的是为了使用Spring的依赖注入,
所以在applicationConte…
[/Quote]


正确
Kaka272827267 2009-04-08
  • 打赏
  • 举报
回复
applicationContext.xml文件放在了WEB-INF下,配置如下:
.
.
.
换一下吧,放SRC下面
APOLLO_TS 2009-04-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zhoushaolan 的回复:]
type="org.springframework.web.struts.DelegatingActionProxy"> 这个是把action交给spring管理,用spring的IOC容器来造action.
并且在spring中声明就可以了
<bean name="/user" class="web.action.UserAction">
    <property name="userBiz" ref="userBiz" />
</bean>
[/Quote]

2.5 用 id比较多吧!

id=user 好像没/

<bean id="user" class="web.action.UserAction">
<property name="userBiz" ref="userBiz" />
</bean>
zhoushaolan 2009-04-07
  • 打赏
  • 举报
回复
type="org.springframework.web.struts.DelegatingActionProxy"> 这个是把action交给spring管理,用spring的IOC容器来造action.
并且在spring中声明就可以了
<bean name="/user" class="web.action.UserAction">
<property name="userBiz" ref="userBiz" />
</bean>
jsyz3838131 2009-04-07
  • 打赏
  • 举报
回复

看上去好像没什么问题也
 
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="pathnames" value="/WEB-INF/actoin-servlet.xml;classpath:applicationContext.xml" />
</plug-in>

这样试试看,要不然,不使用plugin的方法 配置到容器里,在web.xml里面配置listener 监听

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>


也可以不使用spring的代理类

<action
attribute="userForm"
input="/user.jsp"
name="userForm"
parameter="operate"
path="/user"
scope="request"
type="web.action.UserAction">
<forward name="index" path="/index.jsp" />
<forward name="error" path="/error.jsp" />
</action>
<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">//不改变action的type属性
</controller>

关注!


dadi5566 2009-04-07
  • 打赏
  • 举报
回复
web.action.UserAction
文件中可能有问题
yangfeitarena 2009-04-07
  • 打赏
  • 举报
回复
type="org.springframework.web.struts.DelegatingActionProxy"> 是要讲你的action交给spring来管理,所以你要在applictionContext.xml中创建一个bean
<bean name="/user" 
class="web.action.UserAction" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
<property name="">
<ref bean="" />
</property>
</bean>

  • 打赏
  • 举报
回复
你贴出来的代码没有什么错误

你既然使用Spring的Action代理
<bean name="/user" class="web.action.UserAction" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
<property name="userBiz">
<ref bean="userBiz"> </ref>
</property>
</bean>

就要把你的 Action中定义的属性增加setXXX()方法,
这样做的目的是为了使用Spring的依赖注入,
所以在applicationContext.xml配置文件中还要配置Action类所对应的的Bean,
这样在运行时可以讲这些Bean注入到Action类中
加载更多回复(3)

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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