SpringBoot简单的REST风格例子

原文链接: http://www.cnblogs.com/Guhongying/p/10512858.html

关于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 }

然后实现的效果如下:

转载于:https://www.cnblogs.com/Guhongying/p/10512858.html

猜你喜欢

转载自blog.csdn.net/weixin_30496431/article/details/94943713