java - Action errors are not shown on the JSP -


i have tried adding action errors in action class , printing them on jsp page.

when exception occurred, going catch block , printing "error in inserting exception, contact admin", in console.

in catch block, i've added addactionerror(), , i've tried printing in jsp page...
but message not shown in jsp page.

what may 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 {         // stuff...     } catch (numberformatexception e) {         addactionerror("error in inserting exception, contact admin");         system.out.println("error in inserting exception, contact admin");         e.printstacktrace();     }     return success; } 

jsp code printing action errors:

<s:if test="hasactionerrors()">     <br></br>     <div class="errors">         <font color="red">             <s:actionerror/>         </font>     </div> </s:if> 

when perform redirectaction, new request created, , hence actionmessages, actionerrors, along other parameters (not expressly declared passed in struts config) lost.

then

  • use default dispatcher result instead of redirectaction result, or
  • use messagestore interceptor preserve errors , messages across redirects, or
  • return different result of type dispatcher in case of errors, eg. error:

    <action name="dataupdate" class="foo.bar.myaction" method="updation">     <result name="success" type="redirectaction">....redirecttodataupdate</result>     <result name="error">previouspage.jsp</result> </action> 
    public string updation() {     try {         // stuff...         return success;     } catch (numberformatexception e) {         addactionerror("errors... ");         e.printstacktrace();         return error;     } } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -