I have tried adding action errors in the Action class and printing them on the JSP page.
When an exception occurred, it is going into the catch block and it is printing "Error in inserting the Exception, Contact the Admin", in console.
In the catch block, I've added it with addActionError()
, and I've tried printing it in jsp page...
but the message is not shown in jsp page.
What I may be missing or doing wrong ?
Struts mapping:
<action name="dataUpdate" class="foo.bar.myAction" method="updation">
<result name="success" type="redirectAction">
../Aggregator/redirectToDataUpdate
</result>
</action>
Action class:
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 code for printing action errors:
<s:if test="hasActionErrors()">
<br></br>
<div class="errors">
<font color="red">
<s:actionerror/>
</font>
</div>
</s:if>