response.getWriter().write() for ajax

 1. If you don't jump to the ajax call background, you will not jump and will only return. At most, the page that returns to the jump is paid for the data parameter (@ResponseBody, or response.getWriter().write())

  

response.getWriter().write():

1.1 If there are multiple ifs (response.getWriter().write()), if you do not write return, it will continue to execute downward. Generally, a function with a return is used, and then return null,

If it is one, it is not necessary for the function to have a return type,

 

1.2 Another aspect is also conducive to synthesizing the results of returning HTML directly. Add @ResponseBody in the head of the method (cannot be added, if it is added, it will not return to the jump page

will only return the string or the entire page string)

  1.2.1 You can use ajax datatype:html to return to the page (not a jump), when you want to return to the complete page, use @ResponseBody to return the rules, which must conform to the datatype

  1.2.2 You can also use response.getWriter().write() to return local html code, so as to combine their respective advantages

1.3 When response.getWriter().write(), return null meets any format requirements of datatype, and then it can return its own (high priority) (can be mixed)

 

                2. If you want to jump, you can't return with ajax

 

 

 1, 2 can be mixed in one method

For an example, see the ChatController.java---"TbConOrdPriceGetRecord method in the attachment

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326402315&siteId=291194637