我使用 apt-get
在我的 Ubuntu 12.04 服务器上安装了 Tomcat 7。
据我了解,我只需要上传包含 .jsp
文件的项目目录和包含 web.xml
文件的 WEB-INF
目录。
基本路径:/usr/share/tomcat7-root/default-root/test/
index.jsp: /usr/share/tomcat7-root/default-root/test/index.jsp
web.xml: /usr/share/tomcat7-root/default-root/test/WEB-INF/web.xml
index.jsp 文件内容:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<% out.println("this is a test"); %>
</body>
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" 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>test</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
当我去
mydomain:8080/test/index.jsp
我收到以下错误:
HTTP Status 404 - /test/index.jsp
type Status report
message /test/index.jsp
description The requested resource (/test/index.jsp) is not available.
Apache Tomcat/7.0.26
我导航到正确的目录了吗? Tomcat 登陆页面加载 its fine!
页面没有错误,所以我假设 Tomcat 运行正常。
我是不是对 web.xml 属性或文件结构做错了什么?
编辑 - 打字错误
最佳答案
在 Ubuntu 服务器上使用 apt-get
的 Tomcat 7 的正确目录是 /var/lib/tomcat7/webapps/ROOT/
。
关于java - 无法在 Tomcat 7 ubuntu 服务器上运行 .jsp 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23828063/