Spring接收请求参数:
1,使用HttpServletRequest获取
Java代码
@RequestMapping("/login.do")
public String login(HttpServletRequest request){
String name = request.getParameter("name")
String pass = request.getParameter("pass")
}
2,Spring会自动将表单参数注入到方法参数,和表单的name属性保持一致。和Struts2一样
Java代码
@RequestMapping("/login")
public String login(HttpServletRequest request,
String name,
@RequestParam("pass")String password) // 表单属性是pass,用变量password接收
{
log.info(name);
log.info(password)
}