Administrator
发布于 2023-05-29 / 76 阅读 / 0 评论 / 0 点赞

JAVA springboot实现hello world

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项目

18602216-b4b8df54d70b6b32.webp

启动springboot项目

3.访问编写的HelloController类(接口)

在浏览器上输入:http://127.0.0.1:8080/hello
18602216-7fae3e07bbee49c7.webp

运行结果

3.接口说明

18602216-8572864371a7414b.webp

接口请求说明

4.java注释说明

18602216-bf7c138b81ef9cbc.webp


评论