参数传递乱码 加密解密

package test;

import java.net.URLDecoder;
import java.net.URLEncoder;

public class Ceshi {
	public static void main(String[] args) {
		doc();
	}
	
	public static void doc() {
		try {
			String str = "juapk.com?userName=轻描@淡写.%*";
			String strEncode = URLEncoder.encode(str, "UTF-8");
			String strDecode = URLDecoder.decode(strEncode, "UTF-8");
			System.out.println("原始字符串:" + str);
			System.out.println("URLEncoder.encode加密:" + strEncode);
			System.out.println("URLDecoder.decode解密:" + strDecode);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}

  

posted @ 2020-12-28 10:09  红尘沙漏  阅读(112)  评论(0编辑  收藏  举报