【SpringMVC】RestFul

@Controller
public class RestFulController {

    //原来: http://localhost:8080/add?a=1&b=2
    //RestFul: http://localhost:8080/add/a/b

    //@RequestMapping(value = "/add/{a}/{b}", method = RequestMethod.GET)
    @RequestMapping("/add/{a}/{b}")
    public String test(@PathVariable int a, @PathVariable int b, Model model) {
        int result = a + b;
        model.addAttribute("msg", "结果为:" + result);
        return "test";
    }
}

【SpringMVC】RestFul

上一篇:Restful API 定制404返回结果


下一篇:SpringBoot Restful API 请求响应总结