第一个springboot-web快速入门工程-/hello
This commit is contained in:
@@ -13,18 +13,25 @@
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.7.6</spring-boot.version>
|
||||
</properties>
|
||||
|
||||
<!--项目依赖-->
|
||||
<dependencies>
|
||||
<!--springboot-web起步依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--springboot集成的junit单元测试起步依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<!--springboot版本控制-->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@@ -3,6 +3,7 @@ package com.inmind;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
//定义当前类为springboot的启动项
|
||||
@SpringBootApplication
|
||||
public class SpringbootWebQuickstartApplication {
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user