Spring框架下 get方法传中文 乱码

来源:互联网 发布:json 转数组 编辑:程序博客网 时间:2024/05/01 02:14

之前采用其他的方法,发现IE下的解决方案不适用于FirFox等,适用FirFox的方案又不适用于IE,所以找到一个两者都适用的解决方法真不容易;

此方法,只适用于Spring框架的原因,是框架帮助解码一次;

前台

url: contextPath + "/getalltimes2.do?type='" + escape(encodeURI("演讲")) + "'",

两次编码

后台

public List<TestTime> getAllTestTimes2(String type) throws UnsupportedEncodingException {        type = URLDecoder.decode(type, "utf-8");        .....}

只需解码一次,大功告成。

0 0
原创粉丝点击