struts.xml

  struts2配置文件,因为我们为Action配置了拦截器,默认的拦截器就会失效。为了程序的正常运行,需要我们显示引入默认拦截器。

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
 3 <struts>
 4     <package name="lee" extends="struts-default" namespace="/">
 5            <interceptors >
 6             <interceptor name="log"  class="Interceptor.Myinterceptor"></interceptor>
 7         </interceptors> 
 8         <action name="Login" class="Action.LoginAction" >
 9             <result name="input">index.jsp</result>    
10             <result name="success">WEB-INF/success.jsp</result>
11              <interceptor-ref name="log"/> 
12              <!-- 我们为一个Action配置了拦截器时,默认的拦截器就会失效,
13              但是Struts2本身的一些功能,比如说参数自动赋值又是依赖配置的默认拦截器实现,
14              所有应用程序会出错。这时需要我们手动将默认的拦截器引用进来,再为这项Action加入默认拦截器 -->
15              <interceptor-ref name="defaultStack"/>
16         </action>
17 
18     </package>
19 
20 </struts>    
View Code

相关文章:

  • 2021-10-04
  • 2021-08-30
  • 2021-06-09
  • 2021-06-16
猜你喜欢
  • 2022-02-21
  • 2022-12-23
  • 2021-11-04
  • 2021-08-29
  • 2021-07-15
相关资源
相似解决方案