url后参数的转码与解码
import java.net.URLDecoder;
import java.net.URLEncoder;
String strTest = "?=abc?中%1&2<3,4>";
strTest = URLEncoder.encode(strTest, "UTF-8");
System.out.println(strTest);
strTest = URLDecoder.decode(strTest,"UTF-8");
System.out.println(strTest);
执行结果:
%3F%3Dabc%3F%E4%B8%AD%251%262%3C3%2C4%3E
?=abc?中%1&2<3,4>
jdk相关说明:
java.net..encode( s, enc) throws
Translates a string into application/x-www-form-urlencoded
format using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.
Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.
Parameters:
s String
to be translated.
enc The name of a supported character encoding.
Returns:
the translated String
.
Throws:
UnsupportedEncodingException - If the named encoding is not supported
Since:
1.4
See Also:
URLDecoder.decode(java.lang.String, java.lang.String)
java.net..decode( s, enc) throws
Decodes a application/x-www-form-urlencoded
string using a specific encoding scheme. The supplied encoding is used to determine what characters are represented by any consecutive sequences of the form "%xy
".
Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.
Parameters:
s the String
to decode
enc The name of a supported character encoding.
Returns:
the newly decoded String
Throws:
UnsupportedEncodingException - If character encoding needs to be consulted, but named character encoding is not supported
Since:
1.4
See Also:
URLEncoder.encode(java.lang.String, java.lang.String)
分享到:
相关推荐
主要介绍了java 使用 URLDecoder 和 URLEncoder 对中文字符进行编码和解码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
使用URLDecoder和URLEncoder 区别
URLEncoder与URLDecoder的应用 对中文字符进行utf-8编码与解码 希望对各位有用
J2ME URLEncoder 和 URLDecoder 类的实现 实现J2ME没有的API
j2ME URLEncoder Vs URLDEcoder
java中的URLEncoder和URLDecoder类.docx
主要给大家介绍了关于java中URLEncoder.encode与URLDecoder.decode处理url特殊参数的方法,文中介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
自己写的,可能有bug,请大家一块学习 环境为PB12 函数(及参数) 作用 arraysort 对一维数组进行排序 ...urldecode 将指定字符串以进行指定字符集url解码 urlencode 将指定字符串以进行指定字符集url编码 涨价了,哈哈
通过URLEncoder.encode加密地址栏url上得中文字符, 并可通过java.net.URLDecoder.decode(str, charset)解密中文
C++ 版本UrlEncoder编码解码工具:支持ANSIC和UTF8格式,是URLEncoderHTML 格式编码的实用工具类。详情参照文章:...
UniEncoder解码库-可以快速解码和编码,日常开发中经常会进行对字符串的各种编码和解码,很方便。
主要介绍了java 使用URLDecoder和URLEncoder对中文进行处理的相关资料,需要的朋友可以参考下
在做一个公告浏览功能时,只要通过url传递的某参数值中包含 & 或 ,就会出现问题–该变量的值无法显示。 问题定位结果: 遇到&时,该参数的值会自动截断,导致参数值传递有误。 二、问题的解决 java代码中做如下...
主要为大家详细介绍了UrlDecoder和UrlEncoder使用方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
HTML 格式编码的实用工具类。该类包含了将 String 转换为 application/x-www-form-urlencoded MIME 格式的静态方法。下文通过实例代码给大家介绍Java中的UrlDecoder 和 UrlEncoder知识,感兴趣的的朋友一起看看吧
支持UTF8、16、32编解码。
JSP页面内容介绍 index.jsp 登录表单界面,默认勾选十天记住登录 提交表单执行doLogin.jsp逻辑 ...否则跟第一次访问输入框为空一样 doLogin.jsp ...遍历客户端的cookie,使用URLDecoder解码获取用户信息
表达式引擎:URL编码器附加组件用于Expression Engine 3或更高版本的附加组件,可使用PHP 函数或函数对字符串进行url编码。安装将urlencoder目录复制到您的system / user / addons文件夹中登录到Expression Engine...
NULL 博文链接:https://wulinhaoxia5.iteye.com/blog/1567999
urlencoder 在Node.js中实现Java Land URLEncoder安装$ npm install urlencoder 例子超级简单: var encoder = require ( 'urlencoder' ) ;encoder . encode ( '哈哈' ) ;执照麻省理工学院