java url 解码 编码 奇怪的解码两次

        String city="北京市";
        String code_1= URLEncoder.encode(city, "utf-8");
        System.out.println(code_1); 
        
        String code_2= URLEncoder.encode(code_1, "utf-8");
        System.out.println(code_2); 
        
        
        String input = "%25E5%258C%2597%25E4%25BA%25AC%25E5%25B8%2582";
        String encoding="utf-8";
        String output=URLDecoder.decode(input, encoding);        
        System.out.println(URLDecoder.decode(output, encoding)); //用正确的编码来解码

posted on 2012-09-05 11:57  雨渐渐  阅读(440)  评论(0编辑  收藏  举报

导航