Struts2的拦截器不起作用

时间:2015-04-05 16:20:21

标签: java struts2

   <?xml version="1.0" encoding="utf-8" ?>
   <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts         Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
   <struts>
   <!-- methods -->
   These are other programs code that will use to config something.
   <constant name="struts.action.excludePattern" value="ws://*"/>
   <constant name="struts.action.excludePattern" value="servlet"/>
   <constant name="struts.enable.DynamicMethodInvocation" value="false"/>
   <constant name="struts.devMode" value="false"/>
   <constant name="struts.configuration.xml.reload" value="true"/>
   <constant name="struts.i18n.encoding" value="UTF-8"/>
   <constant name="struts.custom.i18n.resources" value="message"></constant>
   <constant name="struts.multipart.maxSize" value="16777216"/>
   <constant name="struts.objectFactory" value="spring"/>
   <constant name="struts.ognl.allowStaticMethodAccess" value="true"/>
   <package name="webDefaultStruts" extends="struts-default">       
   </package>
   <constant name="struts.convention.default.parent.package" value="default"/>
   <package name="mobileDefaultStruts" extends="json-default">
   <interceptors>
        <interceptor name="ordinaryUserInterceptor" class="cn.edu.fudan.web.interceptor.OrdinaryUserInterceptor"/>  
        <interceptor-stack name="interceptor_lo"> 
        <interceptor-ref name="ordinaryUserInterceptor" />
        <interceptor-ref name="defaultStack" />  
      </interceptor-stack> 
      </interceptors>
      <default-interceptor-ref name="interceptor_lo"/>
      <global-results>  
        <result name="login" type="redirect">login.jsp</result>  
      </global-results>    
      </package>
      <include file="strutsconfig/web/*.xml"/>
      <include file="strutsconfig/mobile/*.xml"/>
      <constant name="struts.multipart.saveDir" value="/tmp"/>
      </struts>

这是另一个用于配置动作的struts.xml。这是一个测试拦截器是否有用的示例。

<action name="countMyFriends" class="FriendAction" method="countMyFriends">
     <interceptor-ref name="interceptor_lo"/>  
    <result type="json">
        <param name="includeProperties">
            result,
            error
        </param>
    </result>
</action>
这是我的struts.xml,我是拦截器的新手,我试了很多次,但是拦截器不起作用,我不知道为什么,请告诉我哪里是我的错?以及如何修改它。

0 个答案:

没有答案