Java Config で DeferredResult を使用すると、応答本文が空になります。
コントローラ:
@Controller
public class HomeController {
@RequestMapping("/")
public DeferredResult<ModelAndView> home() {
final DeferredResult<ModelAndView> result = new DeferredResult<>();
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
result.setResult(new ModelAndView("home", Collections.singletonMap("name", "World")));
}
}, 2);
return result;
}
}
構成:
@Configuration
@ComponentScan(basePackages = "to.talk.gzip.test")
@PropertySource(value = "classpath:/application.properties")
@EnableWebMvc
public class AppConfig {
@Bean
public ViewResolver mustacheViewResolver() {
MustacheViewResolver resolver = new MustacheViewResolver();
resolver.setPrefix("views/");
resolver.setSuffix(".html");
return resolver;
}
}