Response body is empty when using DeferredResult with Java Config.
Controller:
@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:
@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;
}
}