gpt4 book ai didi

java - 404 错误未与错误页面映射

转载 作者:行者123 更新时间:2023-11-30 11:29:49 24 4
gpt4 key购买 nike

我已经配置了 web.xml 如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<!-- Config here. -->
<servlet>
<servlet-name>SpringConfig</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>SpringConfig</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath: SpringConfig.xml</param-value>
</context-param>

<listener>

<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>

</listener>

<error-page>
<exception-type>404</exception-type>
<location>/404error.html</location>
</error-page>

</web-app>

这是我位于 WebContent 文件夹中的简单 404error.html 页面:

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
The Page You Are Looking For Is Not Available.
</body>
</html>

但我没有获得自定义页面,你们能告诉我我缺少什么吗?

最佳答案

试试这个。它在我的所有应用程序中都运行良好。

<error-page>
<error-code>404</error-code>
<location>/404error.html</location>
</error-page>

关于java - 404 错误未与错误页面映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18111759/

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