2016-04-28 65 views
2

我面臨着一個奇怪的問題之後添加的.html,我沒有安裝的httpd比如Tomcat的反向代理盈,然後開始面對以下問題JasperReportsViewResolver一段時間

org.springframework.context.ApplicationContextException: Could not load JasperReports report from class path resource [static/jasper/rpt_delivery.html.jrxml]; nested exc 
eption is java.io.FileNotFoundException: class path resource [static/jasper/rpt_delivery.html.jrxml] cannot be opened because it does not exist 
     at org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.loadReport(AbstractJasperReportsView.java:529) 

,如果我爲Tomcat做重新啓動,每一件事情都很好,但在10分鐘後我開始出現上述錯誤,問題是資源應該被解析爲/statc/jasper/rpt_delivery.jrxml,我不知道從哪裏開始html,代碼從一年左右開始運行。

@Bean 
    public JasperReportsViewResolver getJasperReportsViewResolver() { 
     JasperReportsViewResolver resolver = new JasperReportsViewResolver(); 
     resolver.setPrefix("classpath:/static/jasper/"); 
     resolver.setSuffix(".jrxml"); 
     resolver.setReportDataKey("datasource"); 
     resolver.setViewNames("rpt_*"); 
     resolver.setViewClass(JasperReportsMultiFormatView.class); 
     resolver.setOrder(0); 
     return resolver; 
    } 

    @Bean 
    public ClassLoaderTemplateResolver templateResolver() { 
     ClassLoaderTemplateResolver result = new ClassLoaderTemplateResolver(); 
     result.setPrefix("templates/"); 
     result.setSuffix(".html"); 
     result.setTemplateMode("HTML5"); 
     result.setCacheable(properties.isCache()); 
     result.setOrder(1); 
     return result; 
    } 
+2

我增加產生=「應用程序/ PDF格式; charset = UTF-8「到控制器的方法,直到現在它工作良好 – Shahbour

+0

你幫我找到了解決這個問題的方法http://stackoverflow.com/questions/43508899/spring-modelandview-issue-adding- HTML前綴/ 43532476#43532476 – Lev

回答

0

正如上面我的意見做幫助別人我張貼它作爲一個問題的答案

添加produces = "application/pdf;charset=UTF-8"的伎倆,現在它正在很好