【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

相关推荐
xinjia_ctrl13 分钟前
暑假实习总结
git·后端·spring·maven·intellij-idea
liangsheng_g21 分钟前
SpringAOP拦截器链递归与事务钩子补偿源码实战
java·spring
SL_staff26 分钟前
制造业私有化文档平台的技术实践:从知识孤岛到可追溯知识资产
java·spring·开源
SL_staff2 小时前
3天上线OKR系统:一名HR与1名工程师如何用JVS完成全栈交付
java·低代码·开源
2501_933923252 小时前
统一功能:统一返回格式+统一异常处理
spring·java-ee·状态模式·统一数据返回
wzdark3 小时前
基于链表的内存池设计与内存复用机制4
java·数据结构·链表
cnkeysky3 小时前
idea 中的 maven 项目重新加载子模块
java·idea
Escalating_xu3 小时前
【System V 信号量】从 P/V 原语到 Builder 封装:写出可控、可清理的进程互斥组件
java·linux·开发语言·jvm
今天AI了吗4 小时前
什么是 AI Agent?它与直接调用大模型 API 有何区别
java·网络·人工智能·架构·java-ee
步行cgn4 小时前
Spring 注入 Map 集合详解
数据库·python·spring