struts2的配置问题,求高手指点

Vivian_2048 2014-07-27 08:53:47
在使用struts2的时候,启动时报错,调了一天,在网上搜集了些解决方案都没有解决,求高手指点。

环境配置情况如下:
工程的lib包(公司不能发图片):
WEB-INF\lib\antlr-2.7.2.jar
WEB-INF\lib\commons-fileupload-1.2.2.jar
WEB-INF\lib\commons-io-2.0.1.jar
WEB-INF\lib\commons-lang3-3.1.jar
WEB-INF\lib\commons-logging-api-1.1.jar
WEB-INF\lib\freemarker-2.3.19.jar
WEB-INF\lib\javassist-3.11.0.GA.jar
WEB-INF\lib\ognl-3.0.6.jar
WEB-INF\lib\struts2-core-2.3.8.jar
WEB-INF\lib\struts2-json-plugin-2.3.8.jar
WEB-INF\lib\xwork-core-2.3.8.jar

web.xml filter配置如下:
<filter>
<filter-name>struts</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

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

<struts>
<package name="bme" extends="struts-default,json-default" namespace="/">
<action name="networkTopology" class="*****Service" method="***">
<result name="fail"></result>
<result type="json">
<param name="root">******</param>
</result>
</action>
</package>
</struts>

错误信息:
严重: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
。。。。
Caused by: Unable to load file:/D:/01_code/mobile/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/msp/WEB-INF/classes/struts.xml - [unknown location]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:1022)
。。。。。
2014-7-27 20:44:50 org.apache.catalina.core.StandardContext filterStart
...全文
243 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuanyuanlee184 2014-07-28
  • 打赏
  • 举报
回复
如果工程和包没有问题的话, 有两种情况。 project菜单中。build automatically取消了自动构建。 这时可以选上build automatically或在工程上右键。构建工程。 还有一种情况就是你在工程属性java build path中source把源代码输出路径改了
Vivian_2048 2014-07-28
  • 打赏
  • 举报
回复
引用 3 楼 yuanyuanlee184 的回复:
还有一种可能就是struts.xml的DTD等版本不对,可以在你所使用的struts-core.jar中,查看strut-default.xml的格式,看下DTD等文件头的版本是多少,struts.xml中保持一致就可以了。
感谢,确实是DTD版本的问题,改成2.0DTD版本就好了,当时的具体错误信息供参考: Caused by: Connection timed out: connect - [unknown location] at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:115) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:885) ... 35 more 还有一个坑是我的工程struts.xml文件因某种原因,总是不能刷新,clean也不好使,虽然改了好几次但不能生效。 手动删除拷贝过去后ok了。
yuanyuanlee184 2014-07-27
  • 打赏
  • 举报
回复
还有一种可能就是struts.xml的DTD等版本不对,可以在你所使用的struts-core.jar中,查看strut-default.xml的格式,看下DTD等文件头的版本是多少,struts.xml中保持一致就可以了。
yuanyuanlee184 2014-07-27
  • 打赏
  • 举报
回复
若有具体异常提示,可能是struts.xml的写法或者配置有问题。
yuanyuanlee184 2014-07-27
  • 打赏
  • 举报
回复
struts.xml [unknown location]后是否还有其他具体错误,如下文中的红色字体等 Caused by: Unable to load file:/E:/apache-tomcat-6.0.16/webapps/Test/WEB-INF/classes/struts.xml - [unknown location] at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:890) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:144) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:111) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:164) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) ... 30 more Caused by: E:\apache-tomcat-6.0.16\webapps\Test\WEB-INF\classes\unknown.dtd (系统找不到指定的文件。) - [unknown location] at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:115) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:885) ... 34 more Caused by: java.io.FileNotFoundException: E:\apache-tomcat-6.0.16\webapps\Test\WEB-INF\classes\unknown.dtd (系统找不到指定的文件。) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:106) at java.io.FileInputStream.<init>(FileInputStream.java:66) at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70) at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:653)

5,657

社区成员

发帖
与我相关
我的任务
社区描述
Web开发应用服务器相关讨论专区
社区管理员
  • 应用服务器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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