springmvc的model.addAttribute用法

首先我理解的model.addAttribute的作用:向前台传送数据

1、此Demo只单纯的实现传值并跳转页面,在controller层的对应方法中,应用model.addAttribute形势如下:

 @RequestMapping("/toShowResume")
    public String toShowResume(String resume,Model model){
        System.err.println("进来去显示简历的后端了");
        System.err.println(resume);
        model.addAttribute("resume",resume);
        return "showResume";
    }

2、controller层控制跳转到showResume后,便可以直接通过el表达式 ${}获取到该值如下

 ${resume}

你可能感兴趣的:(springmvc的model.addAttribute用法)