I am using String 2 in my web application. I write the code to check the user session in the interceptor, but when I return the code as } How do I get JSON objects as feedback from interceptor? Please help me solve this problem. Your code has multiplyable errors. Use the status code to set Response status: and the error code to send an error (the server client may have some sender end that is not the serialized JSON): And then read client-side in the AJAX callback function. net.sf.json.JSONObject , reset its reset object and empty set for the object Please. Please check my code.
Import net.sf.json.JSONObject; Import com.opensymphony.xwork2.interceptor.Interceptor; Public class authority interceptor interceptor applied {JSONObject feedback = new JSONObject (); Public string interruption {try {map session = invocation.getInvocationContext} GetSession (); If (session.get ("userId") == tap) {response.put ("errorCode", "SESSION_OUT"); Withdrawal support.ERROR; } And {System.out.println ("found the session"); Object Action = Involvement. Gate action (); Return invocation.invoke (); }} Hold (exception e) {return ActionSupport.ERROR; }} Public JSONObject getResponse () {Return response; } Public Zero Set Response (JasonOnbise Response) {this.response = response; }
& lt; Name of the result = "error" type = "json" & gt; & Lt; Param name = "status code" & gt; 304 & lt; / Param & gt; & Lt; / Results & gt;
& lt; Name of the result = "error" type = "Jason" & gt; & Lt; Param name = "errorCode" & gt; 404 & lt; / Param & gt; & Lt; / Results & gt;
No comments:
Post a Comment