在 tomcat 的 webapps 的工程目錄下(例如 my-app) 創建 WEB-INF 文件夾
在 WEB-INF 文件夾下創建 web.xml
在web.xml 中填入一下內容
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/web-app_2_5.xsd"
id="scplatform" version="2.5">
<display-name>/</display-name><!--/webName/-->
<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>
</web-app>
做測試時,使用 ctrl+shift+delete 清空頁面緩存後再進行測試