要求:使用 Springboot 开发一个 web 程序,浏览器发起请求/hello后,给浏览器返回字符串 hello springboot
 
 使用 springboot 只需要引入一个起步依赖
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>
这个就包含了使用 SSM 完成此需求时所需要的所有依赖
 然后再编写一个 controller 就可以了:
@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello(){
        return "hello world~";
    }
}

创建项目模块






 

编写代码
- 创建 controller 类

package com.itheima.springbootquickstart.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello(){
        return "Hello world~";
    }
}
启动 springboot
 
 
案例测试




















