SpringMVC 中参数的传递与获取

下面这段代码即实现了路径的映射,
也实现了参数的获取
以及redirect
 @RequestMapping(value ="/login/{name}/{passwd}",method = RequestMethod.GET)
    public ModelAndView login(@PathVariable(value="name") String name,@PathVariable(value="passwd") String passwd)
    {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/result");
        modelAndView.addObject("name", name);
        modelAndView.addObject("password",passwd);
        modelAndView.addObject("message","保存用户成功!");
        System.out.println("username");
        System.out.println("username>>"+name);
        return modelAndView;
    }

你可能感兴趣的:(SpringMVC 中参数的传递与获取)