-
17 Oct 2011 10:20 AM #1
Answered: Java + Struts 2 + Ext - How to use failure method?
Answered: Java + Struts 2 + Ext - How to use failure method?
How can I handle and error on Struts 2 and send it to Ext in a way I can get it on failure?
I tried using a specific jsp with exception-mapping but I was going to success.
If I let the error come, the response text is and page from tomcat.
I would like to receive in the same way but if the message was my error message.
What I'm doing know is setting success false but I'm not confortable with that.
Does anyone is using the failure method for the requests and can get the error message?
Thanks
-
Best Answer Posted by skirtle
Have you tried setting the status code for the response? If you return as 4xx or 5xx error it should go to the failure handler.
http://en.wikipedia.org/wiki/HTTP_status_code
-
17 Oct 2011 12:40 PM #2
Have you tried setting the status code for the response? If you return as 4xx or 5xx error it should go to the failure handler.
http://en.wikipedia.org/wiki/HTTP_status_code
-
21 Oct 2011 8:23 AM #3
That worked. Thanks!
What I did on struts.xml
errorExt.jsp:Code:<global-results> <result name="errorExt">/errorPages/errorExt.jsp</result> </global-results> <global-exception-mappings> <exception-mapping exception="br.com.g3.exception.G3Exception" result="errorExt" /> </global-exception-mappings>
Sending the error:Code:<%=request.getAttribute("errorExt")%>
Code:this.response.setStatus(500); G3Error g3error = new G3Error(errorCode, erroMsg); String errorString = this.getJSONSerializer().serialize(g3error); request.setAttribute("errorExt", errorString);


Reply With Quote