1、在jsp页面两次encodeURI
var path = encodeURI(encodeURI("${archives.attachment}"));
2、在controller进行decoder
attachment = URLDecoder.decode(attachment,"UTF-8");
URLEncoder与 URLDecoder
例子
try {
String encodeStr = URLEncoder.encode("中国", "utf-8");
System.out.println("处理后:" + encodeStr);
String decodeStr = URLDecoder.decode(encodeStr, "utf-8");
System.out.println("解码:" + decodeStr);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
结果:
处理后:%E4%B8%AD%E5%9B%BD
解码:中国