struts2问题

struts2问题


今天在写strut项目的时候,突然访问不了index.jsp页面,老是404错误,我打开Manager app 发现项目没有启动,我的第一感觉是我的xml文件配置有错误,我仔细检查了struts.xml和web.xml发现并没有错误,最后发现启动Tomcat有异常发生

Unable to load configuration. - Class: java.net.AbstractPlainSocketImpl
File: AbstractPlainSocketImpl.java
Method: connect
Line: 178 - java/net/AbstractPlainSocketImpl.java:178:-1
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:436)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4572)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5215)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: Unable to load file:/C:/apache-tomcat-8.5.5/webapps/ognlExpression/WEB-INF/classes/struts.xml - Class: java.net.AbstractPlainSocketImpl

原来是我的struts.xml引入的dtd约束是只能是在联网下使用
这里我那我的举例:

解决方案:
方案一
找到struts架包里面的struts2-core-2.3.1.jar————>struts-default.xml
复制里面的约束在电脑没有联网的时候也可以使用了
方案二
先拷贝已经导入的连接:http://struts.apache.org/dtds/struts-2.3.dtd

    

步骤如下

1.Myeclipse的window
2.Preference
3.在搜索框搜索XML选择XML Catalog
4.右边点击[add]
5.点击[File System]指定你的本地dtd文件的位置
<注意:本地dtd文件是从struts2-core-xx.jar解压出来的>
6.下面的【key type】选择【uri】默认是【public id】
7.【key】的值就是最开始复制的struts.xml文件里面的”http://struts.apache.org/dtds/struts-2.3.dtd”

你可能感兴趣的:(Struts2)