本來在項目的web.xml中就可以通過:
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
然後再做一個404頁面就好了.
後來發現,因爲配置了虛擬路徑,還有在本地解析了域名,再這樣配置就不好了,不知道爲什麼了...
後來解決了:
出來在項目中配置404錯誤並新建404頁面外,還要在%TOMCAT_HOME%/conf/web.xml中加上:
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
也不知道這是什麼原理,調了很長時間才通了...