服务器端的 JavaScript 和 CSS 的 404 错误

404 errors for javascripts and css at server end

本文关键字:错误 CSS JavaScript 服务器端      更新时间:2023-09-26

我想知道为什么对于 js 或 css 或图像的 404 错误,容器/应用程序服务器不会在 Web 中配置的浏览器中显示错误页面.xml。以及如何知道哪个文件导致了web.xml配置的错误页面中的404错误。我需要使错误页面中的用户会话无效,但我想知道哪种类型的文件或哪个文件导致了 404 错误。

我的网站.xml看起来像这样

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"       
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
    <welcome-file>page1.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/page2.jsp</location>
</error-page>
</web-app>

页1.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>
<script type="text/javascript" src="abc.js"></script>
</head>
<body>
<%
System.out.println("page 1");
%>
</body>
</html>

在此示例应用程序中,abc.js 不存在。
页2.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> 
<%
 System.out.println("page 2");
 System.out.println(request.getRequestURI());
%>
</body>
</html>

我得到的输出是:-

page 2    
/Test404/page2.jsp

我想知道为什么第 1 页没有在控制台中打印。

我还想知道哪个文件(在本例中为 abc.js)导致 page2.jsp 运行。

任何帮助将不胜感激。谢谢

我用Xenu来找到这些。 试试吧,你会喜欢的!