JasperReports:未出现下载对话框

时间:2013-10-25 08:19:25

标签: java spring web-applications jasper-reports weblogic

我的 Java Web应用程序出现问题( WebLogic 10.3.5 Spring 3.1 JasperReports 5.0.1 < / em>)我想导出 Excel 报告,但在操作结束时,不会显示下载对话框。在 Tomcat AS 中,一切正常,但 WebLogic 中没有。

带导出按钮的Jsp代码:

<a title="Export" href="javascript:window.location.replace('<%=path %>/admin/export.com');">Export</a>

Spring MVC Controller:

@RequestMapping("/export.com")
public ModelAndView exportAction(@ModelAttribute("model") UserModel model, HttpServletRequest request) throws Exception{
    SearchBean searchForm = model.getSearchForm();
    Map<String,Object> parameterMap = new HashMap<String,Object>();
    List<User>usersList = iReportService.getUsers(searchForm,null).getResults();
    JRDataSource JRdataSource = new JRBeanCollectionDataSource(usersList);
    parameterMap.put("datasource", JRdataSource);
    return new ModelAndView("XlsUserReport",parameterMap);
}

的pom.xml

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>5.0.1</version>
    <exclusions>
        <exclusion>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
        </exclusion>
        <exclusion>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>1.7.0</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.6</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>

FE-servlet.xml中

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass">
        <value>org.springframework.web.servlet.view.tiles2.TilesView</value>
        <property name="order" value="1"/>
    </property>
</bean>
<bean class="org.springframework.web.servlet.view.XmlViewResolver">
    <property name="location" value="/WEB-INF/report.xml"/>
    <property name="order" value="0"/>
</bean>

report.xml将

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
    <bean id="XlsUserReport"
        class="org.springframework.web.servlet.view.jasperreports.JasperReportsXlsView"
        p:url="classpath:report/report/user.jrxml"
        p:reportDataKey="datasource">
        <property name="headers">
            <props>
                <prop key="Content-Disposition">
                    attachment; filename=users.xls
                </prop>
            </props>
        </property>
    </bean>
</beans>

在同一个春天的上下文中,我使用了两个不同的解析器(UrlBasedViewResolver和XmlViewResolver),所以这可能会产生问题。
正如我所说,在 Tomcat AS 中,会出现下载对话框,但是当我在 WebLogic 中部署我的Web应用程序时,导出后会出现一个空白页面(URL为.. ./export.com)

0 个答案:

没有答案