gpt4 book ai didi

java - 从 Eclipse 运行 web.xml 导致 HTTP 状态 404

转载 作者:行者123 更新时间:2023-11-29 03:28:28 26 4
gpt4 key购买 nike

我正在使用适用于 Web 开发人员的 Eclipse Java EE IDE 和 Tomcat 7 在 Windows 7 上工作。

我项目的层次结构是:

enter image description here

当我运行以下 web.xml 时,这意味着我从 Eclipse 中按 CTRL+F11 以获取以下 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>LoginExample</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

我明白了:

enter image description here

enter image description here

我不明白是什么原因造成的,有人知道吗?

这是 index.jsp :

<%@ page language="java" 
contentType="text/html; charset=windows-1256"
pageEncoding="windows-1256"
%>

<!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=windows-1256">
<title>Login Page</title>
</head>

<body>
<form action="LoginServlet">

Please enter your username
<input type="text" name="un"/><br>

Please enter your password
<input type="text" name="pw"/>

<input type="submit" value="submit">

</form>
</body>
</html>

谢谢

最佳答案

WEB-INF 是一个 protected 文件夹,servlet 容器(在您的情况下是 Tomcat)不允许您访问它。如果有人可以查看您的 Web 应用程序设置(尤其是安全设置),那就太糟糕了。只需转到 localhost:8080/LoginExample/index.jsp,然后您就可以看到您的页面。

关于java - 从 Eclipse 运行 web.xml 导致 HTTP 状态 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19752275/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com