Idea version of spring boot web entry case (Hello World!) graphic tutorial

1. Open Idea to create a springboot web project:

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

2. The directory after the project is created:

Insert picture description here

3. Create a controller package at the same level as the program entry under demo, and create a OneController class under the package:

Insert picture description here
Insert picture description here
Insert picture description here

4. Write the code for the OneController class:

package com.springboot.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * @author Yang TanYing
 * @Description:
 * @create 2020-11-24 8:14
 */
@Controller//标明此类是控制层的
public class OneController {
    
    
    @RequestMapping("/hello")//指定控制器可以处理名为("/hello")的URL请求
    public String hello(){
    
    //定一个hello()方法并返回"Hello World!"字符串
        return "Hello World!";
    }
}


5. Run the program, you can see that springboot comes with TomCat, the port number is: 8080:

Insert picture description here
Insert picture description here

6. Open the browser and enter in the address bar: http://localhost:8080/hello

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44067333/article/details/110005024