struts2下载是在后台返回中文文件名就这样 怎么能让另存为的文件名为中文呢? 5
请求是:down.action?name=xxxx.txt代码:<actionname="down"class="com.cn.Up"method="down"><par...
请求是:down.action?name=xxxx.txt
代码:
<action name="down" class="com.cn.Up" method="down">
<param name="directory">E:\DeskTop\</param>
<result type="stream">
<!-- 指定下载文件的内容类型,text/plain是默认类型 <constant name="struts.action.extension" value="action"/>
-->
<param name="contentType">text/plain</param>
<param name="inputName">input</param>
<param name="contentDisposition">
attachment;filename=${downloadFileName}
</param>
<param name="bufferSize">2048</param>
</result>
</action> 展开
代码:
<action name="down" class="com.cn.Up" method="down">
<param name="directory">E:\DeskTop\</param>
<result type="stream">
<!-- 指定下载文件的内容类型,text/plain是默认类型 <constant name="struts.action.extension" value="action"/>
-->
<param name="contentType">text/plain</param>
<param name="inputName">input</param>
<param name="contentDisposition">
attachment;filename=${downloadFileName}
</param>
<param name="bufferSize">2048</param>
</result>
</action> 展开
2个回答
展开全部
在定代码里面,指定
.setContentType("application/octet-stream");
.setHeader("Location", fileName);
.setHeader("Content-Disposition", "attachment; filename=" + fileName); //同网页编码 fileName
.setContentType("application/octet-stream");
.setHeader("Location", fileName);
.setHeader("Content-Disposition", "attachment; filename=" + fileName); //同网页编码 fileName
追问
还是不行 只要(attachment; filename=" + fileName)只要filename为中文返回的文件名就是.action的后缀
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询