大家好我使用jasperreporter作为报告库,使用spring mvc作为控制器 ,我把这两个用这个
@Bean
JasperReportsViewResolver getJasperReportsViewResolver() {
JasperReportsViewResolver resolver = new JasperReportsViewResolver();
resolver.setPrefix("classpath:/jasperreports/");
resolver.setSuffix(".jasper");
resolver.setReportDataKey("datasource");
resolver.setViewNames("rpt_*");
resolver.setViewClass(JasperReportsMultiFormatView.class);
resolver.setOrder(0);
return resolver;
}
@Bean
public InternalResourceViewResolver getInternalResourceViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
resolver.setOrder(1);
return resolver;
}
@RequestMapping(value = "helloReport4", method = RequestMethod.GET)
public ModelAndView getRpt4(ModelMap modelMap, ModelAndView modelAndView) {
modelMap.put("datasource", getWidgets());
modelMap.put("format", "pdf");
modelAndView = new ModelAndView("rpt_HelloWorld", modelMap);
return modelAndView;
}
以上是配置和控制器 然后我把编译的xxxx.jasper放到webapp目录的某个地方 但是当tomcat运行几个小时,大约十个或更多时,当通过浏览器请求jasper视图时,它会产生错误,如[ java.io.FileNotFoundException:无法加载xxxx.html.jasper的资源 ],在我的路径中,放一些xxxx.jasper 文件,但我只将记者格式设置为 pdf ,有人可以告诉我它!〜