【发布时间】:2016-10-13 13:00:33
【问题描述】:
当我到达不存在的页面时,我得到:
HTTP 错误 404
访问 /swagger-ui.ht 时出现问题。原因:
Not Found
所以要覆盖我创建的码头的 404 错误页面:
WEB-INF/jsp/404.jsp
<html>
<head>
<title>Error Page</title>
</head>
<body>
<p>An error occured, please contact webmaster.</p>
</body>
WEB-INF/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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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">
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/404.jsp</location>
</error-page>
</web-app>
我相信,我需要在 WebMvcConfigurerAdapter 中创建一些 Bean,但我找不到合适的。问题是,我已经有了@RestControllerAdvice,所以这不应该覆盖我的控制器建议。
什么是正确的方法?
【问题讨论】:
标签: java spring jsp spring-mvc jetty