toly1994.com.toly01.controller.HelloSpringBoot
@RestController public class HelloSpringBoot { @RequestMapping(value = "/hello", method = RequestMethod.GET) public String say() { return "HelloSpringBoot"; } } 访问:http://localhost:8080/hello 访问效果注解的方式还有一种,和上面的效果一样
@RestController public class HelloSpringBoot { @GetMapping("/hello") public String say() { return "HelloSpringBoot!"; } }类和方法都有value时
@RestController @RequestMapping(value = "/hello") public class HelloSpringBoot { @GetMapping("/say") public String say() { return "HelloSpringBoot!!"; } } 访问:http://localhost:8080/hello/say配置多url对1映射:
@RestController public class HelloSpringBoot { @GetMapping({"/hello", "/hi"}) public String say() { return "HelloSpringBoot!!!"; } } 访问:http://localhost:8080/hello 或 http://localhost:8080/hi修改配置方式1:src\main\resources\application.properties
#修改端口号 server.port=8081 #端口号后需额外添加字符 server.servlet.context-path=/toly01个人比较喜欢yml
转载于:https://www.cnblogs.com/toly-top/p/9782004.html
相关资源:Android代码-springboot-socks