时间格式--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 {

    @Autowired
    private 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来进行默认值的设定。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值