Java 服务端验证面临的问题
我正在尝试使用spring实现服务器端验证。但这并不是在验证。这是我的代码示例Java 服务端验证面临的问题,java,spring,Java,Spring,我正在尝试使用spring实现服务器端验证。但这并不是在验证。这是我的代码示例 @RestController @RequestMapping("/api/v1/note") public class NoteController { @Autowired private final NoteService noteService; @PostMapping
@RestController
@RequestMapping("/api/v1/note")
public class NoteController {
@Autowired
private final NoteService noteService;
@PostMapping
public ResponseEntity<String> create(@Valid @RequestBody final NoteDto noteDto){
noteService.create(noteDto);
return new ResponseEntity<>("sucess", HttpStatus.CREATED);
}
}
这里缺少的是触发NoteDto验证的有效注释(在本例中为@NotNull和@Future)。这些注释可能来自不同的JSR-303提供程序(例如,Hibernate、Spring等等) 范例 静态类NoteDto{
@NotNull @Future
private Date date;
}
删除final。POJO类如何?有什么错误,如果有,请发布一些stacktrace。
@NotNull @Future
private Date date;
}