SpringBoot簡單的REST風格例子
阿新 • • 發佈:2019-03-11
nbsp tro 單例 pub targe com con https static
關於REST和RESTful的說明請移步至:怎樣用通俗的語言解釋REST,以及RESTful?
其實我自己也不是十分的理解,只是今天學SpringBoot時看到有個標著REST風格的簡單例子,就記錄一下。
代碼如下:
1 @RestController
2 @EnableAutoConfiguration
3 public class Controller {
4
5 //REST風格?
6 @RequestMapping("/index/{msg}") //
7 public String Hello(@PathVariable String msg) {
8 return "你好,"+msg;
9 }
10
11 public static void main(String[] args) {
12 // TODO Auto-generated method stub
13 SpringApplication.run(Controller.class, args);
14
15 }
16
17 }
然後實現的效果如下:
SpringBoot簡單的REST風格例子