【SpringBoot】第4章 Web开发 4.1 Web开发简介

60,23:23

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starer-web</artifactId>

</dependency>

@RestController

public class HelloController{

@RequestMapping("/hello")

public String hello(){

return "hello,world";

}

} 9

@Controller

@RequestMapping("user")

public class UserController{

@RequestMapping("/index")

public String index(){

map.addAttribute("name","thymeleaf-index");

return "thymeleaf/index";

}

}16

@Controller

public class HelloController{

@RequestMapping("/hello")

@ResponseBody

public String hello(){

return "hello,world";

}

}22

@RestController

@RequestMapping("/user")

public class UserController{

@RequestMapping("/getUser")

public User getUser(){

User u = new User();

u.setName("tianlong");

u.setAge(32);

u.setPassword("lysoft");

return u;

}

}32

@Controller

@RequestMapping("/user")

public class UserController{

@RequestMapping("/getUser")

@ResponseBody

public User getUser(){

User u = new User();

u.setName("tianlong");

u.setAge(20);

u.setPassword("123456");

return u;

}

}43

相关推荐
RainbowSea10 小时前
12. LangChain4j + 向量数据库操作详细说明
java·langchain·ai编程
RainbowSea10 小时前
11. LangChain4j + Tools(Function Calling)的使用详细说明
java·langchain·ai编程
考虑考虑14 小时前
Jpa使用union all
java·spring boot·后端
用户37215742613515 小时前
Java 实现 Excel 与 TXT 文本高效互转
java
浮游本尊16 小时前
Java学习第22天 - 云原生与容器化
java
渣哥18 小时前
原来 Java 里线程安全集合有这么多种
java
间彧18 小时前
Spring Boot集成Spring Security完整指南
java
间彧18 小时前
Spring Secutiy基本原理及工作流程
java
Java水解19 小时前
JAVA经典面试题附答案(持续更新版)
java·后端·面试
洛小豆21 小时前
在Java中,Integer.parseInt和Integer.valueOf有什么区别
java·后端·面试