我知道这些问题早先被问到,但给出的任何答案都没有解决我的问题。
我在Eclipse中使用JSP创建了一个名为JSP_web_application_01的Web应用程序,我在ubuntu 12.04 LTS上。我在WebContent目录中有index.jsp文件。我使用命令提示符创建了它的.war文件,为了部署它,我将它放在tomcat的webapps文件夹中,并使用命令sudo $ CATALINA_HOME / bin / shutdown.sh停止tomcat,并再次由sudo $ CATALINA_HOME /启动它bin / startup.sh
它夸大了.war文件(JSP_web_application_01.war)并创建了JSP_web_application_01文件夹结构,当我尝试使用以下命令从浏览器访问它时,我获得的所有内容都是http 404状态代码:
http://localhost:8080/JSP_web_application_01/
我明白了:
HTTP Status 404 - /JSP_web_application_01/
type Status report
message /JSP_web_application_01/
description The requested resource is not available.
Apache Tomcat/7.0.47
这是我的web.xml文件,位于WebContent / WEB-INF文件夹
中<?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" 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>JSP_web_application_01</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
这是我第一次尝试托管网络应用程序。所以,任何帮助将不胜感激。
答案 0 :(得分:0)
您的步骤似乎没问题,将欢迎文件列表替换为单个文件,如果您要加载index.html。那么,
<?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" 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>JSP_web_application_01</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
同样清理并构建项目,以便在将其部署为.war
之前消除错误希望它有所帮助!
答案 1 :(得分:0)
检查项目文件必须在JSP_web_application_01下解压缩,特别是index.jsp。如果正确,请重新启动Web服务器,在$ CATALINA_HOME / logs下拖尾日志文件,检查启动信息是否正确。