HTTP状态 - JSP中的404资源未找到异常

Gir*_*ran 6 java jsp http-status-code-404 java-ee-6

我一直坚持在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>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

Ani*_*rni 14

上面的评论您已将文件放在错误的文件夹中.

将您的index.jsp文件放在WebContent文件夹中.不要放入WEB-INF文件夹.


WebContent文件夹

  • 所有Web资源的强制位置,包括HTML,JSP,图形文件等.
  • 如果文件未放在此目录中(或此目录下的子目录结构中),则在服务器上执行应用程序时,这些文件将不可用.
  • Web内容文件夹表示将部署到服务器的WAR文件的内容.不在Web内容文件夹下的任何文件都被视为开发时资源(例如.java文件,.sql文件和.mif文件),并且在项目进行单元测试或发布时不会部署.

参考