0
我希望使用JasperReport
與Spring MVC
,但我使用InternalResourceViewResolver
作爲處理方法。當我打電話給我的報告方法時,它開始搜索pdfReport.jsp
頁面,並顯示我一個404 not found
。但我需要打開報告文件,而不是.jsp
頁面!賈斯珀報告和InternalResourceViewResolver - 404未找到錯誤
我的控制器方法:
@RequestMapping(method = RequestMethod.GET, value = "/report/{id}")
public ModelAndView generatePdfReport(ModelAndView modelAndView) {
LOG.debug("--------------generate PDF report----------");
Map<String, Object> parameterMap = new HashMap<String, Object>();
java.util.List<Node> nodeList = nodeService.list();
JRDataSource JRdataSource = new JRBeanCollectionDataSource(nodeList);
parameterMap.put("datasource", JRdataSource);
// pdfReport bean has ben declared in the spring configuration
return new ModelAndView("pdfReport", parameterMap);
}
我的Spring XML配置文件:
<mvc:annotation-driven/>
<tx:annotation-driven/>
<context:component-scan base-package="com.datum.fnd">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="contentType" value="text/html; charset=UTF-8" />
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!-- Report pages beans -->
<bean id="pdfReport"
class="org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView"
p:url="classpath:reportTest.jrxml"
p:reportDataKey="datasource" />