Eclipse,Tomcat - 请求的资源不可用JSP

时间:2015-09-12 16:29:00

标签: eclipse jsp tomcat web-inf

为什么不能在服务器上运行我在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>

1 个答案:

答案 0 :(得分:1)

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

这是正常的:这是您存储Web应用程序的整个代码,配置等的地方。

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