【问题标题】:How to schedule a JSP Page?如何调度 JSP 页面?
【发布时间】:2020-08-30 21:49:46
【问题描述】:

我有一个 JSP 页面 task.jsp。所以我想一年只显示一次这个页面,即每年的三月份。

我不知道如何安排它。请帮我。以下是我的示例控制器代码:

@RequestMapping(
    value = "task.htm",
    method = RequestMethod.GET
)

public ModelAndView taskPost(@ModelAttribute("task") Task task, HttpServletRequest request) {
    ModelAndView model = new ModelAndView("task");
    //do something
    return model;
}

【问题讨论】:

    标签: java spring-mvc jsp quartz-scheduler taskscheduler


    【解决方案1】:

    你可以抛出一个ResponseStatusException:

    @RequestMapping(value = "task.htm", method = RequestMethod.GET)
    public ModelAndView taskPost(@ModelAttribute("task") Task task,HttpServletRequest request {
        if(LocalDate.now().getMonth() != Month.MARCH) {
            throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Unable to find resource");
        }
    
        ModelAndView model = new ModelAndView("task");
        //do something
        return model;
    }
    

    查看更多:

    【讨论】:

      猜你喜欢
      • 2013-02-18
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      • 2011-08-04
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      • 1970-01-01
      相关资源
      最近更新 更多