Request Encoding ,Page Encoding,Response Encoding 以及中文乱码的原因

本文详细介绍了Request Encoding、Page Encoding和Response Encoding的概念,以及它们在处理中文数据时可能导致乱码的原因。Request Encoding默认为ISO-8859-1,可以通过JSP的tag来设置。Page Encoding影响JSP文件的编译,优先级从高到低依次是JSP属性组、page指令的pageEncoding属性、contentType的charset属性,若未指定则使用ISO-8859-1。Response Encoding需正确设置以确保字符在特定区域的正确渲染。当这些编码不匹配时,可能出现中文乱码问题。
摘要由CSDN通过智能技术生成

首先先把文档给大家贴过来,

Request Encoding

The request encoding is the character encoding in which parameters in an incoming request are interpreted. Currently, many browsers do not send a request encoding qualifier with theContent-Type header. In such cases, a web container will use the default encoding--ISO-8859-1--to parse request data.

If the client hasn't set character encoding and the request data is encoded with a different encoding from the default, the data won't be interpreted correctly. To remedy this situation, you can use theServletRequest.setCharacterEncoding(String enc) method to override the character encoding supplied by the container. To control the request encoding from JSP pages, you can use the JSTLfmt:requestEncoding tag. You must call the method or tag before parsing any request parameters or reading any input from the request. Calling the method or tag once data has been read will not affect the encoding.

Page Encoding

For JSP pages, the page encoding is the character encoding in which the file is encoded.pageEnc

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值