【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

相关推荐
雨中飘荡的记忆11 小时前
保证金系统入门到实战
java·后端
Nyarlathotep011311 小时前
Java内存模型
java
暮色妖娆丶16 小时前
不过是吃了几年互联网红利罢了,我高估了自己
java·后端·面试
NE_STOP16 小时前
MyBatis-参数处理与查询结果映射
java
狂奔小菜鸡17 小时前
Day40 | Java中的ReadWriteLock读写锁
java·后端·java ee
SimonKing18 小时前
JetBrains 用户狂喜!这个 AI 插件让 IDE 原地进化成「智能编码助手」
java·后端·程序员
狂奔小菜鸡18 小时前
Day39 | Java中更灵活的锁ReentrantLock
java·后端·java ee
NE_STOP1 天前
MyBatis-配置文件解读及MyBatis为何不用编写Mapper接口的实现类
java