struts2工程不联网启动报错!

原来使用的struts1.3,后来升级到struts2+jdk6。tomcat6联网情况下使用正常,不联网时,启动就报异常:
[code="java"]Caused by: java.net.UnknownHostException: struts.apache.org
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:500)
at sun.net.www.http.HttpClient.(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:318)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:792)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:733)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:658)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:981)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1316)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1283)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:283)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1168)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1068)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:988)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:645)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:508)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:78)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:361)
... 27 more[/code]

上网搜索了,看到有人说要使用本地加载DTD文件,于是修改struts.xml文件,为
[code="java"]<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "struts-2.0.dtd">[/code]
struts-2.0.dtd文件放在和struts.xml相同的路径,启动却报了这样一个异常:
[code="java"]Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/struts-2.0.dtd][/code]
重建工程也是一样,请教是什么问题,多谢了!

0

4个回答

我拿 struts2-blank.war 在断网的情况下测试了一下,没发现你说的问题。

像这种莫名其妙的问题,很可能是 jar 包的冲突。你检查一下 struts*.jar,看看是不是有多个不同的版本存在?

你也可以试一下,把 struts2 自带的 struts2-blank.war 放到 tomcat 里断开网络跑一下,看看有没有问题。

0

首先,你要在web.xml里加上类似如下的内容:
[code="xml"]

/WEB-INF/lib/taglib.tld
/WEB-INF/lib/taglib.tld

[/code]

其次,把相关的tag标签定义下载放到指定的目录里,我的例子中,是把 taglib.tld 放到 /WEB-INF/lib/ 目录下。

最后,在 jsp 页面里用类似的代码引用:
[code="java"]
<%@ taglib uri="/WEB-INF/lib/taglib.tld" prefix="s" %>
[/code]

这样就不需要到 internet 上去取标签定义了

0

我用Tomcat 5.5.28 + Struts 2.1.8,我特意把网络断开,好像启动也没看到你说的情况啊。

0

你把tomcat5.5 换成Tomcat v6.0 这样就应该可以

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!