【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

相关推荐
杨运交39 分钟前
[044][Web模块]基于 Google Authenticator 的 TOTP 双因素认证框架设计与实现
spring boot
要开心吖ZSH1 小时前
处方物流信息同步优化:从 36 秒到亚秒级的踩坑记录
java·数据库·mysql·性能优化
Wang's Blog1 小时前
JavaWeb快速入门: MyBatis入门与实战
java·mybatis
EntyIU1 小时前
Java NIO 实战
java·开发语言·nio
二宝哥1 小时前
springboot项目使用Gradle工具实现依赖版本控制
java·spring boot·后端·gradle·版本
济*沧*海2 小时前
Set集合深度解析:原理、特性与应用场景全攻略
java
geovindu2 小时前
java: Singleton Pattern
java·开发语言·后端·单例模式·设计模式·创建型模式
一路向北North2 小时前
Spring Security OAuth2.0(16):密码模式
java·后端·spring
水无痕simon2 小时前
5 多表操作
java·开发语言·数据库
ALex_zry2 小时前
C++26 Freestanding 库扩展详解:无操作系统也能用标准库
java·jvm·c++