您的位置:首页 > 编程语言 > Java开发

struts 2运行和配置中出现错误

2011-03-24 02:14 281 查看
调试struts程序。出现下面错误

错误:

type Status report

message /Struts2/

description The requested resource (/Struts2/) is not available.

其中:web.xml中配置:

<?xml version="1.0" encoding="UTF-8"?>

<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts 2.0 StrutsDemo</display-name>
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

一开始没有进行web.xml配置时候,可以正常运行建立的jsp文件,但是添加了filter过滤器和过滤器映射后,却不能运行。经过检查,其他action文件,struts.xml文件配置均没有错误。后面着重对web。xml进行分析,觉得问题大致出现的可能性:

首先,看包的导入是否完整。一般需要导入的包有:
commons-logging-1.0.4.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.6.jar
xwork-2.0.1.jar
commons-fileupload-1.2.1.jar
commons-io-1.32.jar

其次:就是看你web.xml中是否含有
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
之类的默认显示界面,其中的页面显示的jsp可以自行定义和配置相应的action用于界面的显示

第三:就是看在web.xml中是否有书写错误:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

第四:可能出现的可能性很小
就是可能是用的开发环境和平台的问题.最后是重新又写了几遍才好。

最后的解决方法,我觉得可能是与他的eclipse环境有关。因为同样的程序在我的机子上运行的很顺畅。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐