1. 方式一:使用HttpServletRequest对象

String id = arg0.getParameter("id");
mv.addObject("id", id);

2. 方式二:使用@RequestParam

    @RequestMapping("/news")
    public ModelAndView ShowNews(@RequestParam(value="id", required=false) String strId){

        ModelAndView mv = new ModelAndView("news");

        return mv;
    }
@RequestParam(value="id", required=false) String strId,这句话代表网页可以传入一个名为 “id”的参数,参数值为strId。括弧里面指出参数名为“id”的参数,可以不传入。

 

相关文章:

  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-11-16
  • 2021-12-30
  • 2021-12-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案