struts2下载中文文件乱码

struts2下载中文文件乱码,第1张

最后一段代码

public String getDownloadFileName() throws Exception{

String downFileName =""

try {

downFileName = new String(nameword.getBytes("ISO8859-1"),"UTF-8")

} catch (UnsupportedEncodingException e) {

e.printStackTrace()

}

System.out.println(downFileName)

return downFileName

}

downFileName = new String(nameword.getBytes("ISO8859-1"),"UTF-8")

改为downFileName = new String(nameword.getBytes("ISO-8859-1"), "gbk") 试试,你的问题不知道我里没理解错!

你好:

1. 将项目的workspace设置为utf-8编码

2. 使用new String()的方式

3.一般情况下是不会出现乱码的.

希望可以帮到你

首先<constant name="struts.i18n.encording" value="UTF-8"></constant>

另外考虑可能是tom cat的语言设置问题,在myEclipse的设置里可以搜索tom找到tom cat设置默认语言为UTF-8;

再者页面不仅使用request.setCharacterEncoding(“utf-8”)再加上response.setCharacterEncoding(“utf-8”)

试试看,不行就设置tom cat的自身配置文件http://bbs.csdn.net/topics/380205136;

不行就换个tom cat 7.0。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/11937865.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存