RestFul风格

1、第一版:

@Controller
public class RestFulController {
    @RequestMapping("/add")
    public String test1(int a, int b, Model model){
        int res = a+b;
        model.addAttribute("msg","结果为:"+res);
        return "test";
    }
}

【SpringMVC-03】RestFul风格_其他

2、改为RestFul风格之后:

@Controller
public class RestFulController {
    @RequestMapping("/add/{a}/{b}")
    public String test1(@PathVariable int a, @PathVariable int b, Model model){
        int res = a+b;
        model.addAttribute("msg","结果为:"+res);
        return "test";
    }
}

【SpringMVC-03】RestFul风格_其他_02