使用URLEncoder、URLDecoder进行URL参数的转码与解码
来源:互联网 发布:淘宝大学紫米教育骗 编辑:程序博客网 时间:2024/05/22 17:35
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的大致实现原理
- 又冒出个飞腾CPU
- 浏览器三种刷新方式所采取的缓存机制
- 资料 hibernate中hbm文件中inverse功能
- mysql数据双向同步
- 【小阅读^大脑袋】0412 NO.352 按此在新窗口浏览图片
- 使用URLEncoder、URLDecoder进行URL参数的转码与解码
- vim 高亮设置及自动缩进(转)
- The page you requested, favicon.ico, could not be found. in file **/system/core/Kohana.php on line 841
- mysql取得数据库所有表名和字段注释
- oracle数据库如何清理临时表空间
- 数据库设计中的14个技巧
- Oracle拆分字符串函数
- ExecutorService并发池的应用
- 职场规则(一)