【发布时间】:2015-11-23 23:15:04
【问题描述】:
您好,我是新来的,在 JSP 中遇到问题。在 Eclipse 中,我创建了一个动态 Web 项目。我右键单击 WEB-INF 文件夹以创建一个名为 jsp 的新文件夹。在文件夹 jsp 中,我创建了一个名为“yes.jsp”的新 jsp 文件。 jsp文件是一个简单的jsp文件。
这是yes.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>Yes</title>
</head>
<body>
Yes
</body>
</html>
现在,在我的 web.xml 中,当我想运行 yes.jsp 时,我将 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.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>WEB-INF/jsp/yes.jsp</welcome-file>
</welcome-file-list>
</web-app>
在欢迎文件中,我尝试了各种其他替代方案,例如 jsp/yes.jsp、/jsp/yes.jsp、jsp\yes.jsp
但每次我运行它时,我都会得到类似
的响应HTTP 状态 404 -
输入状态报告
消息
说明请求的资源不可用。
Apache Tomcat/7.0.55
请帮助我了解我哪里出错了。
谢谢!
【问题讨论】:
-
您能发布完整的
web.xml文件吗? -
这是完整的 web.xml 文件,我在问题中复制的那个..
-
请查看下面给出的答案。