【问题标题】:on action error message not showing on same page操作错误消息未显示在同一页面上
【发布时间】:2015-11-25 03:43:59
【问题描述】:

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

<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
}

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

【问题讨论】:

  • 你能展示你的动作类吗?

标签: validation struts2 validationerror


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多