[英]404 error not mapping with error page
我已將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>
這似乎是一個錯字錯誤,您在htm
提到了htm
而不是html
來進行servlet映射的html
,如下所示:
<url-pattern>*.htm</url-pattern>
嘗試將其更改為:
<url-pattern>*.html</url-pattern>
將exception-type
更改為exception-code
<error-page>
<exception-code>404</exception-code>
<location>/404error.html</location>
</error-page>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.