javaEEday05-请求响应-请求-日期参数

This commit is contained in:
2026-09-16 14:44:12 +08:00
parent a008865032
commit a623e80858
@@ -2,10 +2,12 @@ package com.inmind.controller;
import com.inmind.pojo.User;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
@@ -57,4 +59,11 @@ public class RequestController {
return "OK";
}
//日期参数
@RequestMapping( "/dateParam")
public String dateParam(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime updateTime){//由于前端的时间格式的多样性,一般前后端约定固定格式,如yyyy-MM-dd HH:mm:ss,所以这里要用一个注解
System.out.println(updateTime);
return "OK";
}
}