[英]struts2 on tomcat project shows blank page, using Fiddler shows 404 error
我的项目使用的是Tomcat 7.0。
文件结构为:
项目
-src
-项目包
----LogInActon.java
--struts.xml
-网页内容
--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
这是调试的任何线索吗?
根据您的评论,您面临着java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0
当您在原计划使用的其他版本的JRE上运行应用程序时,会遇到此异常。 简而言之,这只是版本不匹配的问题。
版本号51.0
显示您的特定类文件与哪个JRE版本兼容。 51.0
表示JRE7。最有可能的是,与本地主机相比,您在在线服务器上运行的JRE版本不同。
要解决此问题,请确保在与JRE相同的主版本上启动该应用程序。 您必须在导致问题的在线服务器上安装JRE6。
要检查JRE版本,只需启动命令
java -version
在控制台上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.