先写一个404界面(kk.jsp)
<%--
Created by IntelliJ IDEA.
User: ytgOs
Date: 2020/7/1
Time: 15:46
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<h2>这是404界面</h2>
</body>
</html>
配置struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="demo1" extends="struts-default" namespace="/">
<default-action-ref name="error"></default-action-ref>
<action name="error">
<result name="success">kk.jsp</result>
</action>
</package>
</struts>
注意:
1、<default-action-ref>要在<action>前面
2、<default-action-ref>的name要与要在<action>的name对应前面