注意: 返回数据类型用dataType: ‘text’,如果是 dataType: ‘json’,success获取不到
####1.ajax post提交多个参数后台controller @RequestParam方式接收
@RequestMapping(value = “/findPage”,method = RequestMethod.POST)
public String doFindPageByPageNum(@RequestParam(value = “page”) String page, @RequestParam String size,@RequestParam String cartonDetailNum,String cartoonId){
//代码省略
}
这里写代码片
####例子2:
controller接收:
@RequestMapping(value = "/findVideoByCategoryId",method = RequestMethod.POST)
@ResponseBody
public String findVideoByCategoryId( String pageIndex,
String pageSize, String categoryId,HttpServletRequest request,HttpServletResponse response){
//logger.info("----ajax POST 方式提交后台接收-----");
//HttpServletRequest,HttpServletResponse只是用于验证登录token
}
####2. jquery ajax get方式提交单个参数后台controller @RequestParam方式接收
确定
controller:
@RequestMapping(value = "/doWxPayTest",method = RequestMethod.GET)
@ResponseBody
public String dowxPayTest(Model model,@RequestParam String totalFee){
if(!totalFee.equals("")&&totalFee!=null) {
total_fee = Integer.parseInt(totalFee);
}
logger.info("wxPayTest total_fee="+total_fee);
return "y";
}
最后附上,忘记时查看
后台接收POST GET 提交参数的方式总结