因为a标签和js的window.location.href如果携带数据跳转都属于get请求,所以如果带了中文传过去就会乱码。
解决办法:window.location.href=encodeURI(encodeURI("/ds/wx/system/user/toEdit?data=${userDto.name!""}&edit=name"));
用js中用两层encodeURL包起来,当在控制器取的时候用这种方式取URLDecoder.decode(request.getParameter("data"),"utf-8");
因为系统会自动帮我们decode一次,所以对于两层encodeURL我们只需要decode一次就可以了!