。刑赶。。懂衩。撞叨。金踪。
又是ie。
剛開始嘗試了下面的方法:
if (assertIE(request.getHeader("User-Agent"))) {
fileName = URLEncoder.encode(fileName, "UTF-8");
} else {
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1")
}
ie牵敷,6,8,9,10 都可以通過正則msie判斷胡岔,到了11變了,變了枷餐。靶瘸。。毛肋。怨咪。
后面有來了個edge。润匙。诗眨。。孕讳。匠楚。。我不管厂财,我認(rèn)為都是IE芋簿。
于是乎我寫了下面的判斷是否IE的辦法。
private static boolean assertIE(String agent) {
Pattern pattern = Pattern.compile("^.?(msie|trident.rv:|edge).*?$",Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(agent);
return matcher.matches();
}
媽的寫到最后發(fā)現(xiàn)蟀苛。益咬。
fileName = new String(fileName.getBytes("GBK"), "ISO8859-1")
用上面這一行代碼就可以了。帜平。。重點是GBK梅鹦。裆甩。。齐唆。。
但是文件名里面不能有日文,例如钝计,小澤瑪利亞糙申,蒼井空這些。锭弊。堪澎。