路径中带中文出现乱码问题

9/6/2015来源:Java教程人气:4910

路径中带中文出现乱码问题

   做项目的时候我们可能会遇到需要使用路径传参数的问题,如果参数是数字或者英文,那肯定不会出现乱码,但是如果恰巧传递的参数是中文的呢?出现乱码的几率就很大了吧,传递的参数变成了不知道是什么东西,到后台就不好处理了。今天我就遇到了这么个问题,害我一顿纠结,废话不多说,下面说方法:

   如果通过路径传递中文参数,我们需要先对路径进行一下处理,那么久用到了javascript 的encodeURI()函数,这个方法的具体用法如下:

这是w3chool给出的具体的用法,就是在函数中传入一个必须的字符串,这个字符串含有URI或者其他要编码的文本。还有一些不会进行转译的上面也都有,

在前台传递的时候进行编码,在后台取参数的时候再解一下码就可以了。但是在编码的时候却会出现一些问题就是,编码之后再后台接到的参数还是不正确,出现缺失的问题,怎么解决呢?

下面引用一位大神的博客内容:地址:http://blog.163.com/eugeneheen_chen@126/blog/static/120812157201291994916866/

QQZrlYKFCjMDAx/2Z7An0AAAAAACuOkzh49aUbjA03RpwREiUJpwacKB3HiccpUipWkmCSOgusmbeFKfU8YSMQCFl9wUU1cRBF0eHDRyYmJgrFoic4ZVnAAYgDAAAAABgWnMTBy3aNC0aMLReMVqLY/EVpgIAQTCldLoYYaaV1EkdceKakMfKJkQuU2I4HgiesOJiPOZizVMbGRoMgNAXSgAMM3QoAAAAAMDw4iYNrd48bLcAZDXwRJ4m14na0ArfWXWsjFQghNhQxSYRn3QqB8AijaZQiMaZ/1dYdNc+BEOLIsWOrxsYC38fEOgzsGAdkRAIGcQAAAAAAw4BjQOIExdpYcM8IBGp7FgRjaecCimPJCDZiIfA9rKxwEJwZg18slhKZELOJ541s2V4/WmF2dlYqVSwUa56DbDcgDgAAAABgGHASBy/ft8bYbowwZ0RpHSfSaAQjFjxBtNKBZ5QCN+//DMmqlHZMo+BhGCRSJklSLBSaRyvMzMwwLnxPYIJTtwHEHAAAAADAsOAkDm569pZYKmPHozgphX5skArZCEWUWXXOECWMYmVsu+CMEsoFl1pxyozlr485CIIAYX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