书接上回,把Hello World 在页面上显示!

1、在pom文件中加入web支持

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

注意:加入spring-boot-starter-web就可以把spring-boot-starter删除了,spring-boot-starter-web已经包含spring-boot-starter

最终效果:170620、springboot编程之页面版Hello World

2、创建报名com.rick.apps.controller,创建HelloController.java编写代码

@RestController
public class HelloController {

    @RequestMapping("/")
    public String hello(){
        return "Hello World!";
    }
}

170620、springboot编程之页面版Hello World

3、启动项目

到主函数直接run 即可

4、访问页面http://localhost:8080/hello

170620、springboot编程之页面版Hello World

5、项目结构图

170620、springboot编程之页面版Hello World

 

相关文章: