1. 程式人生 > >ajax傳送中文字符到後臺亂碼的解決方法

ajax傳送中文字符到後臺亂碼的解決方法

user username text uri login code $.ajax enc logs

$.ajax({
                url : ‘Login‘,
                type : ‘post‘,
                dataType : ‘text‘,
                data : {
                    "user" :encodeURIComponent(userName),
                },

前端代碼

String name=request.getParameter("user");
        name= URLDecoder.decode(name, "UTF-8"); 

後臺代碼

ajax傳送中文字符到後臺亂碼的解決方法