FileUpload中文乱码
使用fileupload上传文件,有些浏览器会出现乱码. 使用setHeaderEncoding就可以解决.
ServletFileUpload upload = new ServletFileUpload(factory);
String charset = request.getCharacterEncoding();
if (charset != null ) {
upload.setHeaderEncoding(charset);
}
String charset = request.getCharacterEncoding();
if (charset != null ) {
upload.setHeaderEncoding(charset);
}
String charset = request.getCharacterEncoding();
if (charset != null ) value = item.getString(charset);
else value = item.getString();
if (charset != null ) value = item.getString(charset);
else value = item.getString();
注意:获取字符串时,也要在参数位置设置字符集:charset(如"GBK"等)