当前位置: 首页 > news >正文

时间格式--cotroller传递时间参数

时间格式–cotroller传递时间参数

我们的前端控制器controller代码,

package com.forge.controller;import com.forge.common.Result;
import com.forge.entity.Doctor;
import com.forge.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;import java.time.LocalDate;
import java.util.List;//用来生成日志对象
@Slf4j@RestController
public class testCotroller {@Autowiredprivate TestService testService;@GetMapping("/emp")public Result page(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "4") Integer pageSize,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin, @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) {List<Doctor> doc1=testService.page(pageNum,pageSize,begin,end);return Result.success(doc1);}}

我看我们的@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,我们使用注释@DateTimeFormat来规定我们前端给我们的日期的格式。

我们的@RequestParam(defaultValue = "1") Integer pageNum,我们使用@RequestParam来进行默认值的设定。


http://www.mrgr.cn/news/16318.html

相关文章:

  • OJ-0830**
  • 鸿蒙版本号管理问题
  • 【三十四】springboot+easyRule初识规则引擎
  • Node.js与SQLite:为何这对组合是开发者的优选?
  • 【秋招笔试】8.24阿里控股秋招(研发岗)-三语言题解
  • 什么是in-the-wild image(野生图像)?怎么更好的利用这些图像(通过BLIP)
  • 人工智能100个AI术语
  • 21. Map接口中keySet()、values()和entrySet()方法的区别是什么?它们各自返回什么内容?
  • 科技改变搜索习惯:Anytxt Searcher,重新定义你的信息获取方式!
  • 美股DT有没有程序化软件或者指标选股工具
  • nginx部署前端vue项目
  • SpringBoot + Vue实现websocket
  • AI写作神器!这四款免费工具让你文思泉涌
  • 代码生成技术的现状与未来发展方向
  • 卧室无主灯照明布局:打造温馨舒适的私密空间
  • leetcode 147.对链表进行插入排序
  • RK3588 系列之1—串口连接
  • TQRFSOC开发板47DR ADC输入采集测试(二)
  • Mac下的压缩包和Win看到的不一样怎么办 Mac压缩后Win电脑看文件名会乱码
  • Python优化算法18——教与学优化算法(TLBO)