Spring Boot 处理http请求
get请求
请求:
/[value]?[RequestParam]=xxx
代码:
package cn.czwfun;
import org.springframework.web.bind.annotation.*;
/**
* Created by czwin on 2016/11/27.
*/
@RestController
@RequestMapping("/api")
public class CodeforcesAPIHandle {
@RequestMapping(value = "cfapi", method = RequestMethod.GET)
@ResponseBody
public String get(@RequestParam String userid) {
return userid;
}
}
本文介绍了一个使用SpringBoot处理GET请求的示例。通过注解@RequestMapping(value=cfapi method=RequestMethod.GET) 和 @RequestParam 注解,实现了从URL中获取参数并返回的功能。

被折叠的 条评论
为什么被折叠?



