响应机身采用DeferredResult与Java配置的时候是空的。
控制器:
@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;
}
}