java - 无法在 Tomcat 7 ubuntu 服务器上运行 .jsp 文件

标签 java apache jsp tomcat ubuntu

我使用 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/

相关文章:

java - 将字符串存储到数组中?

java - 我到底什么时候应该去内部类(class)

java - 将 JSONObject 从 java web 服务传递到 JSP 页面

java - 如何在 JSP 中将错误消息打印到用户屏幕而不是标准输出?

css - 让 maven 提供像 css.gz 和 js.gz 这样的文件

java - 如何在android中为PhonenumberUtils.PAUSE()提供时间延迟?

java - 带有 Service Pack 2 的 SQL Server Developer Edition 的 jTDS 连接字符串

apache - 可以按需启动的用于 Windows 的简单 HTTP 服务器应用程序?

php - 为什么一个系统中有很多php.ini文件?

php - Laravel 5 每个页面都会返回 404 错误