对web.xml与struts.xml进行配置,防止在自己主页下出现输错网址产生异常.
欢迎页面
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
对web.xml配置防止输错jsp网址等产生异常
<error-page><!-- 修改服务器的配置使整个项目中的jsp错误都能自动跳转 -->
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/errors/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/errors/404.jsp</location>
</error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/errors/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/errors/404.jsp</location>
</error-page>
对struts.xml配置防止输错action网址等产生异常
<package name="default" namespace="/" extends="struts-default">
<!--配置默認action,输错网址自动跳转默认action -->
<default-action-ref name="error"></default-action-ref>
<action name="error">
<result>/errors/404.jsp</result>
</action>
</package>
<!--配置默認action,输错网址自动跳转默认action -->
<default-action-ref name="error"></default-action-ref>
<action name="error">
<result>/errors/404.jsp</result>
</action>
</package>