Java 我能';t使用Spring引导重定向

Java 我能';t使用Spring引导重定向,java,spring,spring-boot,Java,Spring,Spring Boot,我使用springboot@scheduled定期执行任务。我想在任务的周期性执行完成后重定向并跳转到另一个页面。但是,该过程会定期执行并显示消息,但不会执行重定向。 请告诉我 enter code here @Controller @RequestMapping("/index") public class TaskController { @Scheduled(fixedRate = 5000) public String task

我使用springboot@scheduled定期执行任务。我想在任务的周期性执行完成后重定向并跳转到另一个页面。但是,该过程会定期执行并显示消息,但不会执行重定向。 请告诉我

   enter code here  
   @Controller
   @RequestMapping("/index")
   public class TaskController {  
       @Scheduled(fixedRate = 5000)
       public String task(){
              System.out.println("test");
              return "redirect:/index";
       }
   }

使用scheduled注释的方法正在应用程序中运行,没有来自外部的任何交互。因此,没有可以重定向到任何内容的客户端。
您只能从调用的方法重定向,因为它是映射到get或put或任何其他类型请求的方法