在java 设置中配置400,500页面,应该怎么设置,我在网上搜索了,
基本上都是在web.xml中设置:
<!-- 错误 -->
500
/admin/error
404
/admin/notfound//这个地方是不是用了spring mvc就这么写
但是就是跳转不到我的错误页面。
我用了shiro做权限,网上说在web.xml加:
<!-- Shiro Filter is defined in the spring application context: -->
shiroFilter
org.springframework.web.filter.DelegatingFilterProxy
targetFilterLifecycle
true
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
但这个加了,我项目全部的访问路径,都访问不出来,而且也没有访问到我的404页面
怎么问题写出来就是这么个鬼
在web.xml设置
500
/admin/error//这个地方是不是用了spring mvc就这么写
404
/admin/notfound//这个地方是不是用了spring mvc就这么写
<error-page>
<exception-type>500</exception-type>
<location>/admin/error</location>
</error-page>
<error-page>
<exception-type>404</exception-type>
<location>/admin/notfound</location>
</error-page>
忘记说了,还有
在你的404或500页面加上下面两句isErrorPage="true"和<%response.setStatus(HttpServletResponse.SC_OK);%>
加一个拦截器!拦截错误代码返回相应的页面
404是跳转路径有误,检查路径即可,500就是代码编写的问题,要断电调试。
404、500页面可在web.xml中进行配置,也可通过自定义一个拦截器、以及异常处理类来对404、500进行处理