1. Access the action that does not exist in the web. The action that struts2 cannot find will execute the following configuration by default. It is best to set "error" to public. Add the following configuration in struts. xml:
<Default-action-ref name = "error"> </default-action-ref> <global-Results> <result name = "error">/error. JSP </result> </Global-Results>
2. When you access the Action Method in the Web, an error is reported, that is, all Exception Handling. To prevent the error information from being displayed on the page, add the following configuration in struts. xml:
<Global-exception-mappings> <exception-mapping result = "error" exception = "Java. Lang. Exception"> </exception-mapping> </Global-exception-mappings>
3. Access JSP that does not exist in the web. This is configured in Web. XML as follows:
<Error-page> <error-code> 404 </error-code> <location>/error. jsp </location> </error-page>
Error-code indicates the error code, and location indicates the redirection to the page. If this configuration is successful, when the server prompts this error code, it will jump to the location page. Location can be an HTML file or a JSP page.
With the above configuration, you can avoid displaying unnecessary error content in front of the user.