2
目前我想下載的文件名稱爲「downloadStatistic.html」。我想把它改成「無論我想要什麼」。順便說一下,它是一個* .csv文件。如何更改struts中的下載文件名稱
這裏是我的下載操作的代碼:
@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);
}
}
這就是我的支柱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>
我在哪裏可以定義下載文件的文件名?
工程...謝謝 –
我們隨時歡迎您:] –