可以用@ModelAttribute来注解方法参数或方法。带@ModelAttribute创建的参数对象会被添加到Model对象中。注解在参数上时,可以从Form表单或URL参数中获取参数并绑定到model中。

@RequestMapping(value = "/url")
public String process(@ModelAttribute(value = "name") String name){
    return "success";
}

上述代码中,处理url请求时,会创建String对象,值为url请求中的参数“name”的值,并将该对象添加到Model中,在success.jsp中可以在requestScope中引用该对象

相关文章:

  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-02-04
猜你喜欢
  • 2021-11-02
  • 2022-12-23
  • 2021-08-19
  • 2021-11-24
  • 2021-06-14
  • 2022-01-28
  • 2021-12-24
相关资源
相似解决方案