【发布时间】:2013-11-28 04:20:41
【问题描述】:
我的项目使用的是 Tomcat 7.0。
文件结构为:
项目
-src
--项目包
----LogInActon.java
--struts.xml
-网页内容
--Web-INF
----库
------...参考罐子
----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>
项目在本地主机上成功构建,没有错误,完全按预期工作;但是,当我们部署到在线服务器时,它会显示一个空白页面。使用 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
调试有什么线索吗?
【问题讨论】:
-
这是不存在资源的 404。您可以验证您尝试访问的 URL 吗?我最好的猜测是 URL 中有一些混淆。您在 localhost 上点击了哪个 URL,您在服务器上尝试了哪个 URL?
-
你在使用struts2的config-browser插件吗?可能有用。 struts.apache.org/release/2.3.x/docs/config-browser-plugin.html
-
@SaifAsif in localhost 我点击了 localhost:8080/home ,在服务器上是 xxx.com/home,返回不同的结果
-
tomcat 是否在您服务器上的端口
80上运行?默认情况下,tomcat 设置为侦听端口8080。尝试将网址更改为xxx.com:8080/home -
@SaifAsif 嗯,我没有配置它。使用xxx.com:8080/home时,服务会超时;顺便说一句,我不知道 aws elastic beanstalk 是否会将他们的 tomcat 服务器配置为端口 80 ..
标签: java jsp jakarta-ee tomcat struts2