URLEncoder、URLDecoder

	public static void main(String[] args) {
		String a = "欢迎你";
		try {
			//编码(后端传给前端数据之前要先 URLEncoder)
			String b = URLEncoder.encode(a, "UTF-8");
			System.out.println(b);
			//解码(前端传给后端数据,后端接收后要先 URLDecoder)
			String c= URLDecoder.decode(b, "UTF-8");
			System.out.println(c);
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

  

  
posted @ 2018-05-15 15:05  qqyong  阅读(142)  评论(0编辑  收藏  举报