方式比较多:
@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();
}