<action name="addColumn" class="com.Hello"
            method="addColumn">
            <interceptor-ref name="defaultStack" />
            <result name="input" type="chain">showAddColumn</result>
            <result name="success" type="chain">success</result>
        </action>
          <action name="showAddColumn" class="com.Hello"
            method="showAddColumn">
            <interceptor-ref name="defaultStack" />
            <result name="input" >/MyJsp.jsp</result>
            <result name="success" >/MyJsp.jsp</result>    
        </action>
      <action name="hello" class="com.Hello"
            method="addColumn">
            <interceptor-ref name="defaultStack" />
            <result name="input" type="chain">/MyJsp.jsp</result>
            <result name="success" type="chain">/MyJsp.jsp</result>
        </action>
是这么回事,我要添加一条记录,先调用showAddColumn查出少量数据来显示添加的表单,然后提交给addColumn.action,这里面要对提交的数据验证的嘛,比如某个字段不能为空,Hello-validation.xml就是验证,所以呢,如果验证没通过就会返回并打印出错误,验证通过addColumn.action就会提交到数据库里面去。在上面的那个配置中,访问hello.action能够打印出<s:actionerror /><s:fielderror cssStyle="color:red" />,但是访问showAddColumn.action提交空字段就是不行。这里面的区别就是hello.action的错误直接就打印到MyJsp.jsp了,访问addColumn.action的错误就还得通过showAddColumn.action再打印到MyJsp.jsp上。逻辑上又得那么做,怎么实现?求解,或者用其它方法解决这个问题也行,谢谢!

解决方案 »

  1.   

    是不是我打印的MyJsp.jsp有问题,请高手看看,访问hello.action能够打印出错误来,但是
    showAddColumn.action提交空字段就是不行(有验证错误的)
    <%@ page language="java" contentType="text/html; charset=utf-8"%>
    <%@taglib prefix="s" uri="/struts-tags"%>
    <html>
    <head>
    <title>11111</title>
    <s:head />
    </head>
    <body>
    <s:actionerror />
    <s:fielderror cssStyle="color:red" />
    <s:property value="errors.groupName" />
    <s:debug></s:debug>
    </body>
    </html>