【发布时间】:2013-07-04 14:18:13
【问题描述】:
目前,我要下载的文件名为“downloadStatistic.html”。我想将其更改为“我想要的任何东西”。顺便说一下,这是一个 *.csv 文件。
这是我下载操作的代码:
@Scope("prototype")
@Component("/downloadStatistic")
public class StatisticDownloadAction extends DownloadAction {
@Override
protected StreamInfo getStreamInfo(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws Exception {
String filepath = httpServletRequest.getParameter("filepath");
String contentType = "text/comma-separated-values";
File file = new File(filepath);
return new FileStreamInfo(contentType, file);
}
}
这就是我的 struts xml:
<action
path="/shipmentStatistic"
name="shipmentStatisticForm"
scope="request"
validate="false"
type="de.logentis.struts.DelegatingActionProxy"
input="/jsp/statistics/ShipmentStatistic.jsp">
<forward name="back" path="/menu.html" redirect="true"/>
<forward name="download" path="/downloadStatistic.html?filepath={0}" redirect="true"/>
</action>
<action
path="/downloadStatistic"
type="de.logentis.struts.DelegatingActionProxy">
<forward name="back" path="/shipmentStatistic.html" redirect="true"/>
</action>
在哪里可以定义下载文件的文件名?
【问题讨论】:
标签: java download struts filenames