JAVA springboot实现hello world
1.编写HelloController类(接口)
1.创建包:com.xbb.springboot.tutorial.web
2.在上面的包下面创建一个java类:HelloController,内容如下:
package com.xbb.springboot.tutorial.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
@ResponseBody
@RequestMapping("hello")
public String hello() {
return "hello world";
}
}
2.启动springboot项目
启动springboot项目
3.访问编写的HelloController类(接口)
在浏览器上输入:http://127.0.0.1:8080/hello
运行结果
3.接口说明
接口请求说明