是否可以在指定的时间仅安排一次Spring服务方法?例如,当前时间是下午2点,但是当我点击操作按钮时,我希望我的服务方法在晚上8点开始.我熟悉@Scheduled注释,我不知道如何编写cron表达式而不是定期运行.这@Scheduled(cron = "0 0 20 * * ?")一天每天晚上8点开火.
有什么建议?
我正在分析spring-mvc-showcase示例项目(spring-mvc-showcase github).当我点击错误的日期格式(屏幕截图上的出生日期字段)时,在JSP页面上显示验证响应的方式会感到困惑.如何在没有那些ConversionFailedException详细信息的情况下使用某些自定义消息使其更加用户友好?
截图:

应用注释驱动的验证.下面是来自表示birthDate字段的bean类的代码段.
FormBean.java
@DateTimeFormat(iso=ISO.DATE)
@Past
private Date birthDate;
Run Code Online (Sandbox Code Playgroud)
负责表单提交的方法:
FormController.java
@RequestMapping(method=RequestMethod.POST)
public String processSubmit(@Valid FormBean formBean, BindingResult result,
@ModelAttribute("ajaxRequest") boolean ajaxRequest,
Model model, RedirectAttributes redirectAttrs) {
if (result.hasErrors()) {
return null;
}
// Typically you would save to a db and clear the "form" attribute from the session
// via SessionStatus.setCompleted(). For the demo we leave it in the session.
String message = "Form submitted successfully. Bound " + formBean;
// Success response handling
if (ajaxRequest) …Run Code Online (Sandbox Code Playgroud)