博客
关于我
Tomcat+Springmvc中文乱码问题解决方法
阅读量:560 次
发布时间:2019-03-09

本文共 687 字,大约阅读时间需要 2 分钟。

SpringMVC编码配置及乱码解决方案

请求时参数变乱码

在SpringMVC应用中,参数乱码问题常常与字符编码不当有关。为了避免此类问题,可以通过web.xml配置CharacterEncodingFilter进行处理。

    
characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
characterEncodingFilter
/*

返回到浏览器中文显示成乱码

确保返回数据的编码格式正确也是关键。

    response.setContentType("text/html; charset=UTF-8");

上述配置方法能够有效解决参数乱码问题,同时确保页面内容的正确显示。

转载地址:http://sgfpz.baihongyu.com/

你可能感兴趣的文章
Mysql8.0注意url变更写法
查看>>
Mysql8.0的特性
查看>>
MySQL8修改密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
查看>>
MySQL8修改密码的方法
查看>>
Mysql8在Centos上安装后忘记root密码如何重新设置
查看>>
Mysql8在Windows上离线安装时忘记root密码
查看>>
MySQL8找不到my.ini配置文件以及报sql_mode=only_full_group_by解决方案
查看>>
mysql8的安装与卸载
查看>>
MySQL8,体验不一样的安装方式!
查看>>
MySQL: Host '127.0.0.1' is not allowed to connect to this MySQL server
查看>>
Mysql: 对换(替换)两条记录的同一个字段值
查看>>
mysql:Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘解决方法
查看>>
MYSQL:基础——3N范式的表结构设计
查看>>
MYSQL:基础——触发器
查看>>
Mysql:连接报错“closing inbound before receiving peer‘s close_notify”
查看>>
mysqlbinlog报错unknown variable ‘default-character-set=utf8mb4‘
查看>>
mysqldump 参数--lock-tables浅析
查看>>
mysqldump 导出中文乱码
查看>>
mysqldump 导出数据库中每张表的前n条
查看>>
mysqldump: Got error: 1044: Access denied for user ‘xx’@’xx’ to database ‘xx’ when using LOCK TABLES
查看>>