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";
}
}
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";
}
}