zoukankan      html  css  js  c++  java
  • struts2 resultType为chain时 传值

    应用场景:

      a页面保单提交进行validation验证,如果验证不通过则跳转到当前页面并展现已有数据列表,也就是a页面既包含新增表单,又有列表展现。

      一开始的想法是用redirect 类型,可以这个类型明显不行,拿不到验证不通过的信息。

     后来决定用chain,但是跳转是跳转过来,可没有去走chain跳转到action中的方法

    如下列代码:aAction验证不通过,chain到bList,(备注 :1,两个在同一个namespace,2,bList result为input类型的一定要配置)

    但是却没有走listB这个方法,而是直接把验证错误信息展现到b_list.jsp。显然结果不对。 

    <action name="aAction" class="com.AAction" method="detailA">
                <result name="success" type="redirect">AList.html?id=${id}</result>
                <result name="input" type="chain">bList</result>
    </action>

    <action name="bList" class="com.BAction" method="listB">
                <result name="success" type="dispatcher">b_list.jsp</result>
                <result name="input" type="dispatcher">b_list.jsp</result>
    </action>
     

    解决方法:

    <action name="bList" class="com.BAction" method="listB">
                <result name="success" type="dispatcher">b_list.jsp</result>
                <result name="input" type="dispatcher">b_list.jsp</result>
                <interceptor-ref name="default-stack">
                    <param name="workflow.excludeMethods">bList</param>
                </interceptor-ref>
    </action>

    加上这段配置,就可以执行方法后并且一起把错误信息输出到页面。

    补充文章:http://psjay.com/struts2-validate-chain-important-point.html

  • 相关阅读:
    谷歌开发调试工具
    由form表单来说说前后台数据之间的交互
    ajax的post和get请求的使用
    css各属性的理解
    Http Servlet详解及学习地址
    表单详细解释
    JS正则表达式
    jQuery-AJAX简介
    POJ1008 Maya Calendar
    关于Code Blocks无编译器版本及VC6.0插入、打开报错
  • 原文地址:https://www.cnblogs.com/iusmile/p/2581014.html
Copyright © 2011-2022 走看看