当前位置:网站首页>JSP page coding
JSP page coding
2022-04-23 08:25:00 【beinlife】
law :
feasible :utf-8 code --->gbk decode -->gbk code -->utf decode
feasible :utf-8 code --->iso8859-1 decode -->iso8859-1 code -->utf decode
feasible :gbk code --->iso8859-1 decode -->iso8859-1 code -->gbk decode
stay JSP When the page gets the value of the form, there will be garbled code , There are two solutions :
One is to call getParameter Passed before request.setCharacterEncoding Set character encoding ,
The other is called new String(str.getBytes("iso8859-1"), "UTF-8") Decoding after encoding
*/
String s = " Hello ";
// code ----------------------------------------
byte[] utf = s.getBytes("utf-8");
byte[] gbk = s.getBytes("gbk");
System.out.println("---------------------");
System.out.println("gbk Code utf Decode and encode :" + new String((new String(gbk, "utf-8").getBytes("utf-8")),"gbk"));
System.out.println("gbk Code iso8859-1 Decode and encode :" + new String((new String(gbk, "iso8859-1").getBytes("iso8859-1")),"gbk"));
System.out.println("utf Code gbk Decode and encode :" + new String((new String(utf ,"gbk").getBytes("gbk")),"utf-8"));
System.out.println("utf Code iso8859-1 Decode and encode :" + new String((new String(utf, "iso8859-1").getBytes("iso8859-1")),"utf-8"));
System.out.println("---------------------");
System.out.println("iso8859-1 code utf decode :" + new String(s.getBytes("iso8859-1"),"utf-8"));
System.out.println("iso8859-1 code gbk decode :" + new String(s.getBytes("iso8859-1"),"gbk"));
Output results :
---------------------
gbk Code utf Decode and encode : Roller weight copy roller �
gbk Code iso8859-1 Decode and encode : Hello
utf Code gbk Decode and encode : Hello
utf Code iso8859-1 Decode and encode : Hello
---------------------
iso8859-1 code utf decode :??
iso8859-1 code gbk decode :??
版权声明
本文为[beinlife]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230734169115.html
边栏推荐
- DOM 学习之—添加+-按钮
- Queue (C language / linked list)
- Qtablewidget header customization and beautification developed by pyqt5 (with source code download)
- A simple theme of Typecho with beautiful appearance_ Scarfskin source code download
- There are some problems when using numeric type to query string type fields in MySQL
- Kubernetes in browser and IDE | interactive learning platform killercoda
- Transformer XL: attention language modelsbbeyond a fixed length context paper summary
- Weekly leetcode - 06 array topics 7 ~ 739 ~ 50 ~ offer 62 ~ 26 ~ 189 ~ 9
- ansible自动化运维详解(一)ansible的安装部署、参数使用、清单管理、配置文件参数及用户级ansible操作环境构建
- stm32以及freertos 堆栈解析
猜你喜欢
dried food! Point based: differentiable Poisson solver
[learning] audio and video development from scratch (9) -- nuplayer
让地球少些“碳”息 度能在路上
MySQL数据库中delete、truncate、drop原理详解
Rotation function of leetcode medium problem
Community group purchase applet source code + interface DIY + nearby leader + supplier + group collage + recipe + second kill + pre-sale + distribution + live broadcast
Qt读写XML文件
[explanation] get ora-12838: cannot read / modify an object after modifying it in parallel
vslam PPT
Flink SQL实现流批一体
随机推荐
Comparison of indoor positioning technology
WordPress love navigation theme 1.1.3 simple atmosphere website navigation source code website navigation source code
Use of applicationreadyevent
MySQL数据库中delete、truncate、drop原理详解
Detailed explanation of ansible automatic operation and maintenance (I) installation and deployment, parameter use, list management, configuration file parameters and user level ansible operating envi
总线结构概述
Qt编译QtXlsx库
RPC过程
Multi vision slam
npm安装yarn
一键清理项目下pycharm和Jupyter缓存文件
数据的删除和修改操作(mysql)
5.6 综合案例-RTU-
一个必看的微信小程序开发指南1-基础知识了解
CSV column extract column extraction
freertos学习02-队列 stream buffer message buffer
QT reading and writing XML files
DOM 学习之—添加+-按钮
dried food! Point based: differentiable Poisson solver
396. Rotate Function