將DeferredResult與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;
}
}
將它不DeferredResult工作。看起來像最新版本的Jetty中的一個錯誤。 – 2013-05-16 14:22:37
太好了,非常感謝你報告! – 2013-05-30 00:37:41