SpringBoot简单的REST风格例子

时间:2022-06-29 22:09:47

关于REST和RESTful的说明请移步至:怎样用通俗的语言解释REST,以及RESTful?

其实我自己也不是十分的理解,只是今天学SpringBoot时看到有个标着REST风格的简单例子,就记录一下。

代码如下:

 @RestController
@EnableAutoConfiguration
public class Controller { //REST风格?
@RequestMapping("/index/{msg}") //
public String Hello(@PathVariable String msg) {
return "你好,"+msg;
} public static void main(String[] args) {
// TODO Auto-generated method stub
SpringApplication.run(Controller.class, args); } }

然后实现的效果如下:

SpringBoot简单的REST风格例子