Demand analysis: the need to use an Out object to return to the Tenpay to receive success. Then you will need the following code:
[Java] view plain Copy/** * Returns processing results to the Tenpay server. * @param msg:success or fail. * @throws IOException */public void sendtocft (String msg) throws IOException {string strhtml = msg; PrintWriter out = This.gethttpservletresponse (). Getwriter (); Out.println (strhtml); Out.flush (); Out.close (); }
Then the method in the controller is annotated with this method:
[Java] view plain copy//tenpay return URL @ResponseBody @RequestMapping ("/pay/tenpay") pu Blic String Tenpayreturnurl (httpservletrequest request, httpservletresponse response) throws Exception {UNPACKC Ookie (request, response); Payreturnurl.payreturnurl (request, response); return "Pay/success"; }
Using this method, the annotation will output a string on the page visited: strhtml, without jumping to the pay/success.jsp page
The reasons are:
@ResponseBody
Role:
The annotation is used to write the object returned by the controller's method to the body data area of the response object after the appropriate httpmessageconverter is converted to the specified format.
Use time:
The returned data is not a page of HTML tags, but is used in some other form of data (JSON, XML, etc.);
Then just delete the note: @ResponseBody can return to page pay/success.jsp. It also achieves the effect of interacting with the client behind the scenes. That is: [Java] view plain copy out.println (strhtml); And does not output strings on the page.