Recently when doing an internship, click on the query in JS to send AJAX requests to the controller backstage, but no matter how unsuccessful, the request address is correct, because in the background with SYSTEM.OUT.PRINTLN output has value, and indeed return, Baidu later found in the SPRINGMVC annotation. You must add the @responsebody annotation to make the AJAX request successful.
Background Part code:
@RequestMapping ("select.do" ) @ResponseBody // add responsebody to return value, Ajax request succeeds string Selectbydate (HttpServletRequest request, model model) {string B Egin_date = Request.getparameter ("begin_date" ); List <MobileManage> list = Getdatalist (begin_date); Jsonarray json = Jsonarray.fromobject (list); String Pasejson = Pasejson (list); // System.out.println (Json.tostring () ); return Pasejson; }
View Code
Front Section code:
$.ajax ({ type:"POST", URL:"/mylog/mobilemanage/select.do", dataType:" JSON ", data:{begin_date:begin_date}, success:function(data) { processing } })
View Code
Ajax requests are not always successful after they are submitted to the controller