我尝试在Action类中添加操作错误,并在JSP页面上打印它们。当发生异常时,它进入catch块并在控制台上打印“插入异常错误,请联系管理员”。在catch块中,我使用了addActionError(),并尝试在jsp页面中打印它...但是消息没有显示在jsp页面上。我可能错过了什么或做错了什么?Struts映射:
<action name="dataUpdate" class="foo.bar.myAction" method="updation">
<result name="success" type="redirectAction">
../Aggregator/redirectToDataUpdate
</result>
</action>
行动类:
public String updation() throws JiffieTransactionException{
try {
// do stuff...
} catch (NumberFormatException e) {
addActionError("Error in inserting the Exception, Contact the Admin");
System.out.println("Error in inserting the Exception, Contact the Admin");
e.printStackTrace();
}
return SUCCESS;
}
用于打印操作错误的JSP代码:
<s:if test="hasActionErrors()">
<br></br>
<div class="errors">
<font color="red">
<s:actionerror/>
</font>
</div>
</s:if>