on action错误消息未显示在同一页面上

时间:2015-08-31 07:03:33

标签: validation struts2 validationerror

我在同一页面上插入和查看。但问题是没有显示错误信息

<action name="ViewAllCostings" class="volo.tms.costings.Costings" method="ViewAllCostings">
                  <result name="success">/costings/costings.jsp</result>
</action>     

<action name="addcosting" class="volo.tms.costings.Costings">
    <result name="input">/costings/costings.jsp</result>
    <result name="success" type="chain">ViewAllCostings</result>
    <result name="error" >/costings/costings.jsp</result>
</action>

和costings.jsp

<s:actionerror/>
    <s:form action="addcosting" method="post">
    <s:textfield label="Costing Type" name="costtype" required="true"/>
    <s:textfield label="Cost(rs.)" name="costrs" required="true"/>           
    <s:submit value="ADD" name="addcostbutton"/>
</s:form>

<div class="Wrapper">           
    <display:table id="txt" name="costinglist" pagesize="10" cellpadding="2px;" cellspacing="5px;" requestURI="">
        <display:column property="costtype" title="Cost Type" sortable="true"></display:column>
        <display:column property="costrs" title="Cost(rs.)" sortable="true"></display:column>               
    </display:table></div>

和动作类

 public String execute(){//used this method for insert data 
        ArrayList costList = new ArrayList();
        costList.add(costtype);
        costList.add(costrs);
         costList.add(costid);
         if (AddCostDao.insertEditCostDetails(costList)) {
            return SUCCESS;
        } else {
            addActionError("Employee name already exists !");
            return ERROR;
        }}

public String ViewAllCostings(){ 
   //used for view data using list
    return SUCCESS
}

没有收到错误消息。我试过但没有得到解决方案

1 个答案:

答案 0 :(得分:0)

您可能遇到导致INPUT的验证错误,但未执行操作且未设置消息。如果要阻止操作进行验证,可以配置操作以从验证拦截器中排除该方法。就验证拦截器实现方法过滤器拦截器而言,您可以在struts.xml中执行此操作。或者只是在方法上添加@SkipValidation注释。

@SkipValidation
public String execute(){//used this method for insert data