【问题标题】:Eclipse , Tomcat - The requested resource is not available JSP [duplicate]Eclipse,Tomcat - 请求的资源不可用 JSP [重复]
【发布时间】:2015-12-09 01:20:43
【问题描述】:

为什么不能在服务器上运行我放在 webapp/WEB-INF/index.jsp 中的 jsp 文件(Tomcat 显示错误 404 - 请求的资源不可用)但我可以从 webapp/index.jsp 文件夹运行 jsp 文件?

更新

web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
          version="3.0">
<display-name>J2EE Applications Example</display-name>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Test
</body>
</html>

【问题讨论】:

  • 您需要在 web.xml 文件中指定:/WEB-INF/index.jsp

标签: eclipse jsp tomcat web-inf


【解决方案1】:

因为按照设计,WEB-INF 是应用程序的唯一文件夹,无法从外部访问。

这很正常:这是您存储 web 应用程序的整个代码、其配置等的地方。

您真的不希望任何人能够在地址栏中输入/WEB-INF/lib/app.jar 并下载您的 web 应用程序的类。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-26
    • 2013-01-06
    • 1970-01-01
    • 1970-01-01
    • 2016-09-21
    • 2015-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多