![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SpringBoot
storyteller_qzx
这个作者很懒,什么都没留下…
展开
-
SpringBoot控制器接收参数的几种方式
目录1.请求路径参数2.Body参数3.请求头参数4.Cookie参数1.请求路径参数(1)@PathVariableeg.http://192.168.111.111:8080/Demo/control/{id}@PostMapping("/control/{id}")public Result example(@PathVariable("id") String param){ //将路径id位置的值赋给param}(2)@RequestParameg...原创 2020-12-12 17:42:26 · 371 阅读 · 0 评论 -
Java中关于时间的处理:Calendar、Date、Long、String
1.Date相关使用//创建一个指定时间的Date对象:Date(int year, int month, int day)Date date = new Date();//当前时间Date date = new Date(2014-1900, 6-1, 12);//2014年6月12日//获得一个Date对象所包含的信息//获得年份 (注意年份要加上1900,这样才是日期对象d2所代表的年份)int year = d2.getYear() + 1900;//获得月份 (注意月份要加1原创 2020-12-07 14:46:05 · 235 阅读 · 1 评论 -
对List集合按实体的某个属性排序
1.在对应实体类中继承comparable<T>,并实现compareTo方法让需要排序的实体类继承comparable<T>public class Entity implements Comparable<Entity > 在类中实现该接口的compareTo方法(让其按时间(time)排序) @Override public int compareTo(Entity o) { if (this.getTime() &g原创 2020-12-07 14:01:18 · 198 阅读 · 0 评论 -
使用@Scheduled注解在SpringBoot中实现定时任务
实现步骤在启动类加注解@EnableScheduling在定时任务所在类中加注解@Component在定时任务的方法上加@Scheduled(cron=“0/5 * * * * ?”)注:(1)cron表达式:秒 分 时 日 月 周 年(可选)(2)字符① :所有值;如分的位置上是,则每分钟都会触发;月的位置上是*,则每月都触发。② ?:不指定值;使用时不关心该位置;如每年2月1日触发,不关心周几,则周几的位置为?。③ -:区间;月的位置上2-5,表示2,3,4,5月都会触发。④ ,原创 2020-11-11 10:10:01 · 187 阅读 · 0 评论 -
SpringBoot的常用注解
1. 使用在参数上@Valid:对实体尽心校验 @AssertFalse:所注参数为Boolean类型,值为false @AssertTrue:所注参数为Boolean类型,值为true @DecimalMax:所注参数为数字,值小于等于给定值 @DecimalMin:所注参数为数字,值大于等于给定值 @Digits:所注数为数字,且值必须是指定的位数 @Future:所注参数为将来的日期 @Max:所注参数为数字,值小于等于给定值 @Min:所注参数为数字,值大于等于给定值 @Ran原创 2020-11-16 11:14:59 · 214 阅读 · 0 评论