1、进入com.gitblit.utils包下,找到StringUtils类,定位到640行,代码如下:
public static String decodeString(byte [] content, String... charsets) { Set<String> sets = new LinkedHashSet<String>(); if (!ArrayUtils.isEmpty(charsets)) { sets.addAll(Arrays.asList(charsets)); } String value = null; sets.addAll(Arrays.asList("UTF-8", "ISO-8859-1", Charset.defaultCharset().name())); for (String charset : sets) { try { Charset cs = Charset.forName(charset); CharsetDecoder decoder = cs.newDecoder(); CharBuffer buffer = decoder.decode(ByteBuffer.wrap(content)); value = buffer.toString(); break; } catch (CharacterCodingException e) { // ignore and advance to the next charset } catch (IllegalCharsetNameException e) { // ignore illegal charset names } catch (UnsupportedCharsetException e) { // ignore unsupported charsets } } if (value != null && value.startsWith("\uFEFF")) { // strip UTF-8 BOM return value.substring(1); } return value; }
把上面的代码替换为:
public static String decodeString(byte [] content, String... charsets) { Set<String> sets = new LinkedHashSet<String>(); if (!ArrayUtils.isEmpty(charsets)) { sets.addAll(Arrays.asList(charsets)); }else { sets.addAll(Arrays.asList("UTF-8", "ISO-8859-1", Charset.defaultCharset().name())); } String value = null; for (String charset : sets) { try { Charset cs = Charset.forName(charset); CharsetDecoder decoder = cs.newDecoder(); CharBuffer buffer = decoder.decode(ByteBuffer.wrap(content)); value = buffer.toString(); break; } catch (CharacterCodingException e) { // ignore and advance to the next charset } catch (IllegalCharsetNameException e) { // ignore illegal charset names } catch (UnsupportedCharsetException e) { // ignore unsupported charsets } } if (value != null && value.startsWith("\uFEFF")) { // strip UTF-8 BOM return value.substring(1); } return value;
}
重新Ant构建项目
2、修改了本地的:gitblit.properties中的:
#web.blobEncodings = UTF-8 ISO-8859-1
web.blobEncodings = UTF-8 GB2312 ISO-8859-1 UNICODE
3、重新发布应用
注意:本文归作者所有,未经作者允许,不得转载