按道理这应该非常简单,百度一堆,但是竟然每一个方法都没用,而且大部分文字都是爬虫的。
我的方法如下
1、web.xml下加
。。。。。
<error-page>
<error-code>404</error-code>
<location>/html/404.html</location>
</error-page>
</web-app>
2、WEB-INF/下的spring mvc的xml配置文件
<mvc:resources location="/html/" mapping="/html/**"/>
3、webapp或者webContent下,加入html,自定义404页
4、原理
访问一个不存在的url,会出现404错误,然后
(1)程序查找web.xml文件里404配置,对应路径是 /html/404.html
(2)”/html/404.html“在applicationContent.xml里找到<mvc:resources的配置,发现url符合mapping。
(3)把第二步的location取出来,即/html/,也就是webContent/html/404.html