$.ajax請求報400 bad request錯誤
阿新 • • 發佈:2019-02-13
頁面請求程式碼:
$.ajax({
url:"check/checkUser.do",
type:"post",
data:{"mobile=":mobile },
dataType:"json",
contentType:"application/json",
success:function(){
},
});
Controller類UserCheckController 程式碼如下:
@Controller
public classUserCheckController {
@RequestMapping("/check/checkUser.do")
publicModelAndView checkUser(@RequestParam("mobile") Stringmobile){
ModelAndView modelAndView = newModelAndView("/login/login");
System.out.println("1");
return modelAndView;
}
錯誤原因:是因為類UserCheckController的請求處理方法checkUser的引數錯誤
@RequestParam("mobile")String mobile,
改為HttpServletRequestrequest,HttpServletResponse response
網上還有很多別的錯誤型別,我就不列舉了。