我需要一点帮助。我有一个使用 Spring MVC 和磁贴 2 的 Web 应用程序,我昨天添加了 displaytag,但是当我想以任何格式导出表时,我会重定向到一个页面,其中包含一行中的表数据。
这是我的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<filter>
<filter-name>ResponseOverrideFilter</filter-name>
<filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>
<!-- Filter mapping for the export -->
<filter-mapping>
<filter-name>ResponseOverrideFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ResponseOverrideFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- Filter for the export, need that when using Struts and tiles -->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
这是我的jsp文件
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page contentType=" ;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<html>
<head>
<title><spring:message code="label.listeggrafo" /></title>
<style type="text/css">
.pagingItem {
font-weight: normal;
text-decoration: none;
color: #747474;
margin: 0 2px;
padding: 0 2px;
background-color: #eeeeee;
border: 1px solid #bababa;
font-size: 0.9em;
line-height: 1.5em;
}
.pagingItemCurrent {
padding: 0 2px;
margin: 0 2px;
font-weight: normal;
color: #FFFFFF;
background-color: #bfbfbf;
border: 1px solid #bfbfbf;
font-size: 0.9em;
}
</style>
</head>
<body>
<h1><spring:message code="label.listeggrafo" /></h1>
<display:table name="eggrafa" class="table" requestURI="" id="eggrafa" export="true" pagesize="10">
<display:column property="aa" sortable="true" href="update.html" media="html"
paramId="aa" paramProperty="aa" titleKey="label.aa"/>
<display:column property="diabathmisi" sortable="true" titleKey="label.diab"/>
<display:column property="apostoleas" sortable="true" titleKey="label.apostol"/>
<display:column property="tautotitaeg" sortable="true" titleKey="label.tauteg"/>
<display:setProperty name="export.pdf.filename" value="ActorDetails.pdf"/>
<display:setProperty name="export.excel.filename" value="ActorDetails.xls"/>
</display:table>
</body>
这是我的控制器
@RequestMapping(value = "/listeggrafo" , method = RequestMethod.GET)
public ModelAndView listeggrafo(@ModelAttribute("eggrafo") Eggrafo eggrafo,@ModelAttribute("typoi") TypoiEggrafou typoi,HttpSession session,HttpServletRequest request) {
if(session.getAttribute("name")!=null){
Map<String, Object> model1 = new HashMap<String, Object>();
model1.put("eggrafa", articleService.listeggrafa(session.getAttribute("name").toString()));
return new ModelAndView("listeggrafa",model1);
}else{
return new ModelAndView("redirect:/articles/login.html");
}
}
当我选择以任何格式导出时,没有显示下载,只将我重定向到一个页面
http://localhost:8080/Spring3Hibernate/articles/listeggrafo.html?d-1331701-e=3&6578706f7274=1
有谁知道为什么会这样?当我在网上寻找时,有人说这是瓷砖的问题。有什么建议么?