spring mvc controller接收请求值及controller之间跳转及传值
展开全部
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)
}
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)
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询