日期:2014-05-17  浏览次数:20619 次

困扰了一天的struts2拦截器,急
Java code

<package name="hchl" namespace="/hchl" extends="json-default">
        <interceptors>
            <interceptor name="startInterceptor" class="com.inspur.hchl.interceptor.StartInterceptor">
            </interceptor>
            <interceptor-stack name="startInterceptorStack">
                                     <interceptor-ref name="defaultStack"/>
                <interceptor-ref name="startInterceptor"/>
            </interceptor-stack>
        </interceptors>

     <action name="schema_*" class="schemaAction" method="{1}">
             <interceptor-ref name="startInterceptor">
                 <param name="includeMethods">findAllByPage</param>
             </interceptor-ref>
             <result type="json">
                <param name="defaultEncoding">utf-8</param>
            </result>
    </action>
</package>




为什么这里的struts2默认拦截器(defaultStack)不起作用了?从前台form提交的数据封装到action属性中全部为null

------解决方案--------------------
XML code

<package name="hchl" namespace="/hchl" extends="json-default,struts-default">
        <interceptors>
            <interceptor name="startInterceptor" class="com.inspur.hchl.interceptor.StartInterceptor">
            </interceptor>
            <interceptor-stack name="startInterceptorStack">
                <interceptor-ref name="defaultStack"/>
                <interceptor-ref name="startInterceptor"/>
            </interceptor-stack>
        </interceptors>   
        <default-interceptor-ref name="startInterceptorStack" />  
</package>

------解决方案--------------------
<action name="schema_*" class="schemaAction" method="{1}">
<interceptor-ref name="startInterceptorStack">
<param name="includeMethods">findAllByPage</param>
</interceptor-ref>
<result type="json">
<param name="defaultEncoding">utf-8</param>
</result>
</action>

------解决方案--------------------
<package name="hchl" namespace="/hchl" extends="json-default">
<interceptors>
<interceptor name="startInterceptor" class="com.inspur.hchl.interceptor.StartInterceptor">
</interceptor>
<interceptor-stack name="startInterceptorStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="startInterceptor"/> <interceptor-ref name="startInterceptor"/>
</interceptor-stack>
</interceptors>

<action name="schema_*" class="schemaAction" method="{1}">
<interceptor-ref name="startInterceptorStack">
<param name="includeMethods">findAllByPage</param>
</interceptor-ref>
<result type="json">
<param name="defaultEncoding">utf-8</param>