tomcat项目上的struts2显示空白页面,使用Fiddler显示404错误

时间:2013-11-28 04:20:41

标签: java jsp java-ee tomcat struts2

我的项目正在使用Tomcat 7.0。

文件结构为:

  

项目

     

-src

     

- 项目包

     

---- LogInActon.java

     

- struts.xml中

     

-WebContent

     

- WEB-INF

     

---- LIB

     

------...参考罐子

     

---- Web.xml中

     

- index.jsp的

     

- LogInSuccess.jsp

struts.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
   "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
   <package name="homeLogin" extends="struts-default">

      <action name="logIn" 
            class="com.myApp.system.main.actions.LogInAction" 
            method="execute">
            <result name="success">/logInSuccess.jsp</result>
            <result name="fail">/index.jsp</result>
      </action>
   </package>
</struts>

Web.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Welcome</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</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>
</web-app>

和index.jsp(默认主页)是:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
   pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Welcome!</title>
</head>
<body>
   <h1>Log in:</h1>
   <form action="logIn">
      <label for="name">Please enter your name  </label>
      <!--<s:textfield name="username" key="label.name1"/><br/>-->
      <s:textfield name="username"/><br/><br/>
      <label for="pw">Please enter your password    </label>
      <s:password name="pw"/><br/><br/>
      <s:submit value="Log In" align="left"/>
   </form>
</body>
</html>

项目在Localhost上成功构建,没有错误,完全按预期工作;但是,当我们部署到在线服务器时,它会显示一个空白页面。使用Fiddler我看到请求标头是:

GET /home HTTP/1.1
Host: dev-dev1.wherego.ca
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0

,响应头是:

HTTP/1.1 404 Not Found
Date: Thu, 28 Nov 2013 02:50:15 GMT
Server: Apache-Coyote/1.1
Content-Length: 0
Connection: close
Content-Type: text/plain; charset=UTF-8

是调试这个的任何线索??

1 个答案:

答案 0 :(得分:0)

根据您的评论,您正面临java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0

当您在不同版本的JRE上运行应用程序时,会遇到此异常。简而言之,这只是一个版本不匹配的问题。

版本号51.0显示您的特定类文件与哪个JRE版本兼容。 51.0表示JRE 7.最有可能的是,与本地主机相比,您在线服务器上运行的是不同版本的JRE。

要解决此问题,请确保在与其编译的JRE相同的主要版本上启动应用程序。您必须在导致该问题的在线服务器上安装JRE6。

要检查JRE的版本,只需触发命令

java -version

在控制台上。