【发布时间】:2025-12-03 21:30:02
【问题描述】:
我一直坚持在 JSP 中运行 hello world 程序。当我启动服务器时,它显示资源未找到异常。请帮我解决这个问题。我在下面提到了我的代码
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>
</body>
</html>
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_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>MySample</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
【问题讨论】:
-
您如何访问
index.jsp?我的意思是网址。请分享目录结构以进一步帮助您。 -
在 webcontent 文件夹内--> 在 web-inf 文件夹内-->我提到了 index.jsp
-
那是你出错的地方。您必须将
index.jsp放在 WebContent 文件夹中,而不是放在 WEB-INF 中。 -
@Ankiet Kulkarni:感谢您发现我的错误
标签: java jsp http-status-code-404 java-ee-6