当前位置: 首页 > news >正文

TongWeb8编码设置说明

应用场景:

在遇到中文问题时,常需要通过设置编码格式来解决问题。下面介绍TongWeb8的编码设置及优先级。

一、web.xml中请求、响应编码的配置优先级最高

在JavaEE8规范中web.xml增加了request, response编码配置,该配置优先级最高。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://xmlns.jcp.org/xml/ns/javaee"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"id="WebApp_ID" version="4.0"><display-name>charset</display-name><default-context-path>/testde</default-context-path><request-character-encoding>GBK</request-character-encoding><response-character-encoding>GBK</response-character-encoding>  

以往项目中request, response编码通常通过filter来设置,如:

    <filter-name>EncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param><init-param><param-name>forceEncoding</param-name><param-value>true</param-value></init-param>

二、TongWeb8控制台编码设置

在部署应用时通过配置"编码"来完成。

参数

参数说明

应用请求编码

应用程序的默认 HTTP 请求编码,优先级低于web.xml。

应用响应编码

应用程序的默认HTTP响应体编码,优先级低于web.xml。

JSP 文件编码

指定 JSP 文件编码, 相当于javaEncoding。

静态文件编码

使用指定的编码解析应用的文件资源,如 *.html 等静态资源,可用于解决文件编码和 JVM 默认编码不一致引起的乱码问题。相当于fileEncoding

三、URL编码设置

为兼容tomcat编码,http通道中"其它" 中的"URI 编码" 相当于tomcat的URIEncoding ;“URI 使用 Content-Type 解码" 相当于tomcat的useBodyEncodingForURI。

若tomcat下不乱码,而在TongWeb下乱码,则可参考tomcat配置来配置TongWeb。

URIEncoding : This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. The default value is UTF-8.

useBodyEncodingForURI :
This specifies if the encoding specified in contentType should be used for URI query parameters, instead of using the URIEncoding. This setting is present for compatibility with Tomcat 4.1.x, where the encoding specified in the contentType, or explicitly set using Request.setCharacterEncoding method was also used for the parameters from the URL. The default value is false.
Notes: 1) This setting is applied only to the query string of a request. Unlike URIEncoding it does not affect the path portion of a request URI. 2) If request character encoding is not known (is not provided by a browser and is not set by SetCharacterEncodingFilter or a similar filter using Request.setCharacterEncoding method), the default encoding is always "ISO-8859-1". The URIEncoding setting has no effect on this default.

http://www.lryc.cn/news/9563.html

相关文章:

  • 不同相机之间图片像素对应关系求解(单应性矩阵求解)
  • 远程管理时代,还得是智能化PDU才靠得住!
  • 通俗易懂理解——布隆过滤器
  • TypeScript 学习之类型推导
  • Android四大组件——Service详解
  • svg转png
  • 教你如何搭建人事OA-员工管理系统,demo可分享
  • C++递推基础知识
  • 【Python入门第十天】Python 布尔
  • WebDAV之π-Disk派盘+Piktures
  • Revit问题:Navisworks中导入的rvt模型角度不正确调整
  • 最全正则验证
  • 阿里云服务器入门使用流程 新手学习教程
  • git学习
  • 新建一个完整的react项目和完善初始项目
  • HIVE 安装
  • jsp游泳馆门票管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目
  • C++ ---智能指针详解
  • 企业带宽控制管理
  • MybatisPlus实现分页效果并解决错误:cant found IPage for args!
  • C语言赋值(关系)运算符和逗号运算符
  • 几种在Linux/window下查询外网IP的办法。
  • 【nodejs-05】黑马nodejs学习笔记05-数据库基本操作01
  • 零基础、学历无优势、逻辑能力一般”,能转行做程序员吗?
  • 第五章.与学习相关技巧—Batch Normalization
  • Zynq非Video Mixer方案实现视频叠加输出,无需SDK配置,提供工程源码和技术支持
  • 从零实现Web服务器(二): 线程池以及线程池的作用,Get和Post的区别,项目中如何编写数据库连接池,定时器优化非活跃连接
  • 为什么伟大的产品只专注做一件事
  • pycharm远程连接服务器,并单步调试服务器上的代码
  • JVM05 方法区