Apache Tomcat/6.0.13 - Error report <h1 font-familytahomaarialsans-serifcolorwhitebackground-colordfont-sizepx h font-familytahomaarialsans-serifcolorwhitebackground-colordfont-sizepx h font-familytahomaarialsans-serifcolorwhitebackground-colordfont-sizepx body font-familytahomaarialsans-serifcolorblackbackground-colorwhite b font-familytahomaarialsans-serifcolorwhitebackground-colord p font-familytahomaarialsans-serifbackgroundwhitecolorblackfont-sizepxa color blackaname color blackhr color d-->--<
HTTP Status 404 - Servlet action is not available
type Status report
message Servlet action is not available
description The requested resource (Servlet action is not available) is not available.
Apache Tomcat/6.0.13
转网上解决经验一:上网查了好多的答案,网上有很多的解释,出错的地方有很多中,最后我看到一位仁兄的一句话:
“>The requested resource (Servlet action is not available ) is not available
这些都是Struts 或Spring 基本配置出现问题,struts配置在web.xml中检查一下,Spring的配置也是web.xml,确认没有问题 ”,让我缩小了搜索的范围,于是我老老实实的把web.xml 、applicationContext.xml、struts-config.xml这几个文件检查了一遍,不出我所料,在web.xml中我把
|
转网上解决经验二:
天 在调试程序总是出现这么一个问题:the requested resource (action ) is not available 搞了半天都没有弄明白是哪里出问题了 仔细看看自己的struts.xml中的配置也没有什么问题。很是郁闷,于是边玩边学调试着,后来索性还是Google一下吧 结果还真发现自己犯了一个比较愚蠢的问题 其他的地方都是检查过了 唯一就是忘记查看web.xml的配置。回头一看居然里面根本都没有配置相关的filter 这个郁闷啊 怎么就忘记写着东西了呢 所以结果你可想而知啦:服务器到哪里去找那action去啊。
现在将web.xml作用写在这里:web.xml是WEB工程的描述文件,例如WEB工程所用到的Servlet、Filter、Tablib等等等等都在这个里面进行描述,WEB工程启动的时候会在这个里面找到具体所用到的类的路径,由此进行加载。
接下来说说说这一类问题的处理方法:
问题: the requested resource (servlet action is not available ) is not available.
原因:
首先 1.、web.xml文件中未配置ActionServlet。
2、struts-config.xml文件未配置你要访问的Action。
3、你的jsp文件form标记中action属性的路径名称错误。
核查:
1、在web.xml文件中加上ActionServlet的配置信息
- < servlet >
- < servlet-name > action </ servlet-name >
- < servlet-class > org.apache.struts.action.ActionServlet </ servlet-class >
- < init-param >
- < param-name > config </ param-name >
- < param-value > /WEB-INF/struts-config.xml </ param-value >
- </ init-param >
- < init-param >
- < param-name > debug </ param-name >
- < param-value > 0 </ param-value >
- </ init-param >
- < init-param >
- < param-name > detail </ param-name >
- < param-value > 0 </ param-value >
- </ init-param >
- < load-on-startup > 2 </ load-on-startup >
- </ servlet >
2、在struts-config.xml文件检查你要访问的Action配置文件。
3、检查jsp文件form标记中action属性的路径名称是否与struts-config.xml文件中action标记的path属性的路径名称一致。
4、非以上情况的解决办法就是检查web容器的log日志,如果时tomcat则检查下logs目录下的localhost_log文件,看里边是
否记录有错误信息,然后根据错误信息提示将其纠正。
除了以上的 :
也有可能是找不到spring.jar包 。建议重新导入
自己的解决方法: 查看console输出:
1.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource
2.Caused by: java.io.FileNotFoundException: class path resource [com/house/entity/HouseInfo.hbm.xm] cannot be opened because it does not exist
3.Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'developerDao' of bean class [com.house.action.DevelopersAction]: Bean property 'developerDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
看到这里速度回去看,果然是getter/setter出错了:
因为不能解析applicationContext.xml关联到的Action类,其中的getter/setter方法出错导致:
自己的代码如下:
/*public IDevelopersDao getClientInfo() {
return developerDao;
}
public void setClientInfo(IDevelopersDao developer) {
this.developerDao= developer;
}
*/
由于copy自己之前写的相同模块的代码,在写的过程中注重了参数的读取,和路径的书写 ,以为这样一个模块下来不会出错,谁知道忘记了dao类的正确书写也会报404 servlet错,以后要更加小心,当然不免会遇到相似的问题,在此谨记。
也是代码问题,一般不需要重启PC,只要重启tomcat即可。