URLEncoder与URLDecoder
java提供了URLEncoder和URLDecoder类中的两个方法进行编码和解码,可以指定类型进行,编码或者解码,如:
package com.tang.Servlet.test;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
public class test3 {
public static void main(String[] args) throws UnsupportedEncodingException {
String ee = URLEncoder.encode("你好", "UTF-8");
String decode = URLDecoder.decode(ee, "UTF-8");
System.out.println(decode);
}
}