SpringBoot | contrller的使用
@Controller 处理http请求
@RestController Spring4之后新加的注解,原来返回json需要@ResponseBody配合@Controller
@RequestMapping(value = {"/hello", "/hi"}, method = RequestMethod.GET) 配置URL映射,两个url路径都可以访问同一个方法
处理url里面的参数:
@PathVariable 获取url中的数据
@RequestParam 获取请求参数的值
@GetMapping/PostMapping 组合注解(感觉@RequestMapping 参数太长,可以用这些替换)
@PathVariable 获取url中的数据
@GetMapping(value = "/index/{id}")
public String index(@PathVariable("id") Integer id){
return "id: "+ id;
}
@RequestParam 获取请求参数的值
@GetMapping(value = "/detail")
public String detail(@RequestParam("page") Integer page){
return "page: "+ page;
}
SpringBoot | contrller的使用的更多相关文章
- spring boot-18.使用dubbo发布分布式服务
我们新建两个项目分别模拟服务的提供者和服务的消费者,spring boot 集成dubbo主要分为以下几个步骤: 1.安装zookeeper 推荐使用docker 安装,使用以下几个命令即可完成 (1 ...
- springboot项目利用Swagger2生成在线接口文档
Swagger简介. Swagger2是一款restful接口文档在线生成和在线调试工具.很多项目团队利用Swagger自动生成接口文档,保证接口文档和代码同步更新.在线调试.简单地说,你可以利用这个 ...
- springboot+mybatis+maven角色权限框架
发布时间:2018-10-24 技术:springboot,mybatis,maven,shiro 概述 Springboot作为基础框架,使用mybatis作为持久层框架 使用官方推荐的th ...
- 第一个SpringBoot测试实例
1.SpringBoot项目构建:http://start-spring.io 自动化构建SpringBoot项目,保存在本地并解压 2.安装gradle并配置gradle环境 3.配置阿里云ma ...
- 实例讲解Springboot以Template方式整合Redis及序列化问题
1 简介 之前讲过如何通过Docker安装Redis,也讲了Springboot以Repository方式整合Redis,建议阅读后再看本文效果更佳: (1) Docker安装Redis并介绍漂亮的可 ...
- SpringBoot + Layui +Mybatis-plus实现简单后台管理系统(内置安全过滤器)
1. 简介 layui(谐音:类UI)是一款采用自身模块规范编写的前端UI框架,遵循原生HTML/CSS/JS的书写与组织形式,门槛极低,拿来即用.其外在极简,却又不失饱满的内在,体积轻盈,组件丰 ...
- SpringBoot + SpringSecurity + Mybatis-Plus + JWT实现分布式系统认证和授权
1. 简介 Spring Security是一个功能强大且易于扩展的安全框架,主要用于为Java程序提供用户认证(Authentication)和用户授权(Authorization)功能. ...
- 使用VUE+SpringBoot+EasyExcel 整合导入导出数据
使用VUE+SpringBoot+EasyExcel 整合导入导出数据 创建一个普通的maven项目即可 项目目录结构 1 前端 存放在resources/static 下 index.html &l ...
- 解决 Springboot Unable to build Hibernate SessionFactory @Column命名不起作用
问题: Springboot启动报错: Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ...
随机推荐
- Java单例的实现
1.声明实例变量(静态) 2.私有化构造函数 3.创建获取实例的方法 public class Singleton{ //创建实例变量 private static Singleton singlet ...
- AOP和OOP的区别
AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术. AOP与OOP是面向不同领域的两种设计思想. ...
- Creating a .bash_profile on your mac
A typical install of OS X won't create a .bash_profile for you. When you want to run functions from ...
- scala快速学习笔记(三):Collections,包
VI.Collections 1.Array 一些常用方法:println, map( _ * 2), filter(_ % 2 == 0), sum, reserve Array是不可变的, ...
- Continuous integration: The answer to life, the universe, and everything?
Continuous integration is not always the right answer. Here's why. https://techbeacon.com/continuous ...
- 在C++中使用Libmd5计算字符串或文件的MD5值
CppMD5Demo.cpp #include <iostream> #include <fstream> #include <chrono> #include & ...
- HDFS集群安装部署
准备环境: 三台centos7虚拟机(Node-1,Node-2,Node-3) 配置虚拟机网络,保证三台机器可以互相ping通,并且和宿主机可以互相ping通.如果仅仅是作为虚拟机学习,可以关闭防火 ...
- org.eclipse.swt.SWTError: No more handles的解决办法
今天装了JBoss Tools 3.1 插件后,eclipse 打开jsp文件老是报错,或者要我关闭: org.eclipse.swt.SWTError: No more handles 网上找了两个 ...
- leelazero and google colab
https://github.com/gcp/leela-zero/blob/master/COLAB.md 左侧菜单展开,可以查看细节
- bzoj 2301 [HAOI2011]Problem b(莫比乌斯反演+分块优化)
题意:对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. 1≤n≤50000,1≤a≤b≤50000, ...