日期:2014-05-17  浏览次数:21121 次

Tomcat正常启动,却打不开WebRoot目录下的html文件
历史总是很讽刺,两天前我在这儿发帖求助大神解答为什么该出404的地方页面正常显示,现在又要问为啥老是给我404!

描述一下我遇到的问题,和我解决问题时候的努力吧。

今天在美橙买了个虚拟JSP空间,蛋疼的问题来了。项目在本地部署一切正常,访问一切正常。但是到了虚拟主机上,居然连WebRoot根目录下的一个html文件都打不开了。最关键的是启动没有任何报错信息。

经过一番努力,发现了,只要把web.xml里面struts2和spring的监听类注释掉,就可以正常访问jsp和html。

当然这个确实不是解决问题的好办法,总不能不用struts2和spring吧。

加上struts2和spring的侦听,用log4j开debug模式,打印日志的时候发现只打印了两行:
[DEBUG]_2014-04-25 00:41:34 :Stopping filters
[INFO ]_2014-04-25 00:41:34 :Shutting down log4j

虚拟主机提供的Tomcat版本是5.5,和我开发的版本6.0.35不太一致,我又在本地下载了一个5.5版本,居然还是没发现任何问题。

重启了TomcatN次,跟业务人员扯皮扯了半天,那边一口咬定是我程序的问题,好吧。

下面把一些关键代码贴出来,请大神指点一下,这里先谢过了。

web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
   <filter-name>struts2</filter-name>
   <url-pattern>/*</url-pattern>
   </filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>Encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf8</param-value>
</init-param>
</filter>

<!-- log4j context-param -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j-config.properties</param-value>
</context-param>
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
</web-app>


贴上报错的图,无论输入什么,都是这个。


启动日志:
Apr 25, 2014 1:00:29 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib
Apr 25, 2014 1:00:29 AM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-9595
Apr 25, 2014 1:00:2