js编码解码
//对输出结果编码
function encodeStr(val) {
return encodeURIComponent(encodeURIComponent(trim(val)));
}
// 对参数解码
function decodeStr(val) {
return decodeURIComponent(decodeURIComponent(trim(val)));
}
后端解码
public static String urlDecode(String input) {
try {
return URLDecoder.decode(URLDecoder.decode(input, "UTF-8"), "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error("不支持的编码异常" + e.getMessage(), e);
return "";
}
}