首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

困扰了一天的struts2拦截器,该怎么处理

2012-03-23 
困扰了一天的struts2拦截器,急Java codepackage namehchl namespace/hchl extendsjson-default

困扰了一天的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>


</result>
</action>
</package>

热点排行