五、IO流知识点

ListKit 一个基于Stream API的工具类

  返回  

RestFul风格讲解

2021/8/21 19:22:23 浏览:
@Controller
public class RestFulController {

    //原来的:http://localhost:8080/add?a=1&b=2
    //RestFul:http://localhost:8080/add/a/b
    //RequestMapping 默认是get
    @RequestMapping(value = "/add/{a}/{b}",method = RequestMethod.GET)
    public String test1(@PathVariable int a,@PathVariable String b, Model model){
        String res = a + b;
        model.addAttribute("msg","结果为"+res);
        return "test";
    }

    @GetMapping("/add/{a}/{b}")
    public String test2(@PathVariable int a,@PathVariable String b, Model model){
        String res = a + b;
        model.addAttribute("msg","结果为"+res);
        return "test";
    }
    
    @PostMapping("/add/{a}/{b}")
    public String test3(@PathVariable int a,@PathVariable String b, Model model){
        String res = a + b;
        model.addAttribute("msg","结果为"+res);
        return "test";
    }
}

联系我们

如果您对我们的服务有兴趣,请及时和我们联系!

服务热线:18288888888
座机:18288888888
传真:
邮箱:888888@qq.com
地址:郑州市文化路红专路93号