ajax通过post方式传参给后台controller,怎么获取传过来的参数
1个回答
展开全部
方式比较多:
@RequestMapping(value = "/add", method = RequestMethod.POST)
public ModelAndView insert(HttpServletRequest request) {
String name = request.getParameter("name");
碰困世 return new ModelAndView();
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public ModelAndView insert(String name) {
System.out.println(name);
笑肢 return new ModelAndView();
}
public class User{
private String name;
private int age;
//省略 get set
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public ModelAndView insert(User user) {
System.out.println(user.getName());
尺指 return new ModelAndView();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询