2018年06月08日

记录一下今天的收获:
1、下载文件的时候中文文件名为下划线的问题:

response.setHeader("Content-Disposition","attachment;"+
"filename="+ new String(filename.getBytes("UTF8"), "ISO8859-1") );

2、String replaceAll 的时候,如果正则表达式中有$等特殊符号,则失败的问题:

str.replaceAll( Matcher.quoteReplacement(",$,"),Matcher.quoteReplacement("$")) ;

java 文档中的说明是:

Returns a literal replacement String for the specified String. This method produces a String that will work as a literal replacement s in the appendReplacement method of the Matcher class. The String produced will match the sequence of characters in s treated as a literal sequence. Slashes (‘\’) and dollar signs (‘$’) will be given no special meaning.

Leave a Comment

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据