- package com.lk.rw;
- import java.io.UnsupportedEncodingException;
- import java.net.URLDecoder;
- import java.net.URLEncoder;
- import org.junit.Test;
- public class Demo2 {
- @Test
- public void demo() throws UnsupportedEncodingException {
- String noEncode = "你好啊";
- String encode = URLEncoder.encode("你好啊", "UTF-8");
- String browserShowNoEncode = new String(noEncode.getBytes("UTF-8"),
- "GBK");// 代表页面是GBK
- String browserShowEncode = new String(encode.getBytes("UTF-8"), "GBK");// 代表页面是GBK
- System.out.println("未编码浏览器显示:" + browserShowNoEncode);// 浏览器显示的内容
- System.out.println("已编码浏览器显示:" + browserShowEncode);// 浏览器显示的内容
- String tomcatNoEncodeToIso = new String(
- browserShowNoEncode.getBytes("GBK"), "ISO-8859-1");// tomcat按iso解码
- String tomcatEncodeToIso = new String(
- browserShowEncode.getBytes("GBK"), "ISO-8859-1");// tomcat按iso解码
- String str0 = new String(tomcatNoEncodeToIso.getBytes("iso-8859-1"),
- "UTF-8");
- String str1 = new String(tomcatEncodeToIso.getBytes("iso-8859-1"),
- "UTF-8");
- System.out.println("未编码最后接收时:" + str0);
- System.out.println("已编码最后接受时:" + str1);
- // 这步解码是在哪里发生的?
- System.out.println("已编码最后接受时(解码后):" + URLDecoder.decode(str1, "UTF-8"));
- }
- }
复制代码
输出:
求大神 解答下 最后那步解码是在那里发生的???
|
|