【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

相关推荐
WiChP5 小时前
【V0.1B5】从零开始的2D游戏引擎开发之路
java·服务器·数据库
cch89185 小时前
汇编与Java:底层与高层的编程对决
java·开发语言·汇编
荒川之神6 小时前
拉链表概念与基本设计
java·开发语言·数据库
cch89186 小时前
汇编与Go:底层到高层的编程差异
java·汇编·golang
chushiyunen6 小时前
python中的@Property和@Setter
java·开发语言·python
禾小西6 小时前
Java中使用正则表达式核心解析
java·python·正则表达式
2401_895521346 小时前
SpringBoot Maven快速上手
spring boot·后端·maven
yoyo_zzm6 小时前
JAVA (Springboot) i18n国际化语言配置
java·spring boot·python
APIshop6 小时前
Java获取京东商品详情接口(item_get)实战指南
java·linux·数据库