@Past
验证注解或其对应项,如 @PastOrPresent
不处理get方法请求。是否有其他方法(其他注解)来实现此验证,或者我必须在方法体中执行此操作
@ResponseBody
@GetMapping(path = "inquiry/statment/{accountNumber}/{startDate}/{endDate}")
public <T> T accountstatment(
@Valid @PathVariable String accountNumber,
@Valid @PathVariable @Past(message = "start date can not be in the future or present date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
@Valid @PathVariable @PastOrPresent(message = "end date can not be in the future as no transaction have occured in the future,yet!") @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate)
下面是我pom中的依赖项
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.6</version>
</dependency>
暂无答案!
目前还没有任何答案,快来回答吧!