加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – HTTP状态 – 404 JSP中没有找到资源异常

发布时间:2020-12-15 05:11:30 所属栏目:Java 来源:网络整理
导读:参见英文答案 JSP in /WEB-INF returns “HTTP Status 404 The requested resource is not available”????????????????????????????????????2个 我一直坚持在JSP中运行hello world程序.当我启动我的服务器时,它显示资源未找到异常.请帮我解决这个问题.我在
参见英文答案 > JSP in /WEB-INF returns “HTTP Status 404 The requested resource is not available”????????????????????????????????????2个
我一直坚持在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>

解决方法

从 comments above开始,您将文件放在错误的文件夹中.

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

WebContent文件夹

  • The mandatory location of all Web resources,including HTML,JSP,graphic files,and so on.
  • If the files are not placed in this directory (or in a subdirectory structure under this directory),the files will not be available when the application is executed on a server.
  • The Web content folder represents the contents of the WAR file that will be deployed to the server. Any files not under the Web content folder are considered development-time resources (for example,.java files,.sql files,and .mif files),and are not deployed when the project is unit tested or published.

参考

> Dynamic Web projects and applications directory structure in Eclipse IDE

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读