【发布时间】: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