struts2默認攔截器defaultStack


  第一次使用Struts2.3.20,前台頁面向后台傳值,怎么總是提示值為null,查找半天原來是struts配置文件的action中忘記引入defaultStack攔截器了,所以即使Action中萬事(封裝參數的getter和setter)俱備,還是無法達到預期效果。

  使用自定義的攔截器配置在struts配置文件的action中,還要引入defaultStack,否則使用了modelDriven的formBean將不能獲取到form表單中字段的值。

<package name="defaults" extends="json-default">
        <interceptors>
            <interceptor name="methodInterceptor" class="methodInterceptor"></interceptor>
            <interceptor name="loginInterceptor" class="loginInterceptor"></interceptor>
            <interceptor-stack name="loginStack">
                <interceptor-ref name="methodInterceptor"></interceptor-ref>
                <interceptor-ref name="loginInterceptor"></interceptor-ref>
                <interceptor-ref name="defaultStack"></interceptor-ref>
            </interceptor-stack>
        </interceptors>    
        
        <global-results>
            <result name="error" type="redirect">/405.jsp</result>
            <result name="toIndex" type="redirect">index</result>
            <result name="toLogin" type="redirect">login</result>
        </global-results>
    </package>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM