第一个springboot-web快速入门工程-/hello

This commit is contained in:
2025-09-13 17:08:17 +08:00
parent 3502bd304b
commit a81b839b04
4 changed files with 26 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package com.inmind;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//定义当前类为springboot的启动项
@SpringBootApplication
public class SpringbootWebQuickstartApplication {

View File

@@ -0,0 +1,17 @@
package com.inmind.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//表示当前是个请求处理类
@RestController
public class HelloController {
//请求处理方法,当访问/hello资源路径时被hello方法所接收
@RequestMapping("/hello")
public String hello(){
String s = "hello world";
System.out.println(s);
return s;
}
}

View File

@@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
public class BasicController {
// http://127.0.0.1:8080/hello?name=lisi
@RequestMapping("/hello")
@RequestMapping("/hello1111")
@ResponseBody
public String hello(@RequestParam(name = "name", defaultValue = "unknown user") String name) {
return "Hello " + name;