使用URLEncoder、URLDecoder进行URL参数的转码与解码
来源:互联网 发布:dbc2000 装备数据库 编辑:程序博客网 时间:2024/06/13 01:21
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相关说明:
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)
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)
- 使用URLEncoder、URLDecoder进行URL参数的转码与解码
- 使用URLEncoder、URLDecoder进行URL参数的转码与解码
- 使用URLEncoder、URLDecoder进行URL参数的转码与解码 encodeURIComponent编码
- 使用URLEncoder、URLDecoder进行URL参数的转码与解码
- UrlEncoder与URLDecoder编码解码
- 使用URLEncoder和URLDecoder对汉字进行编码和解码
- 通过Ajax的post方式前端参数传到后端与URLEncoder与URLDecoder编解码问题
- URLEncoder.encode与URLDecoder.docode的使用
- java关于URL、URLEncoder、URLDecoder类的使用
- URLEncoder和URLDecoder实现转码和解码
- 编码URLEncoder和解码URLDecoder的UTF-8到GBK的转码
- 编码URLEncoder和解码URLDecoder UTF-8到GBK的转码
- URLDecoder解码、URLEncoder编码
- URLEncoder.encode与URLDecoder.docode传递中文参数编码与解码
- URL编码 百分号编码和解码 URLEncoder和URLDecoder的大致实现原理
- URL编码 百分号编码和解码 URLEncoder和URLDecoder的大致实现原理
- URL编码 百分号编码和解码 URLEncoder和URLDecoder的大致实现原理
- URL编码 百分号编码和解码 URLEncoder和URLDecoder的大致实现原理
- ARM cortex a 的串口通信
- Angularjs 文本框验证
- 面向对象
- spring框架学习(一)
- oracle密码忘了怎么办???
- 使用URLEncoder、URLDecoder进行URL参数的转码与解码
- 欢迎使用CSDN-markdown编辑器
- Eclipse打开图片的插件
- ARM cortex a 之串口通信2
- ON DUPLICATE KEY UPDATE 附带更新条件
- 对屏幕特定部分进行后期特效处理
- Linux 学习
- subversionedge中用户权限的管理
- Sqoop安装配置及将mysql数据导入到hdfs中