SpringBoot簡單的REST風格例子


關於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 }

然后實現的效果如下:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM