解决前后台传递中文参数乱码问题

      https://blog.csdn.net/persistencegoing/article/details/84376427

      All rights reserved.No part of this article may be reproduced or distributed by any means,or stored in a database or retrieval system,without the prior written permission of persistenceGoing author
 

工作中前后台传递中文参数乱码的解决思路

1在搭建项目的初期,一定要配置

 

解决前后台传递中文参数乱码问题_第1张图片这段配置的解释可以看https://starscream.iteye.com/blog/1098880博客

 

2如果使用JSP,可以在顶部添加

<%@ page language="java"  pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
 

 

3在web.xml中添加全局的字符过滤器


    encodingFilter
    com.jorian.web.filter.CharacterEncodingFilter
    true
   
      encoding
      UTF-8
   

   
      forceEncoding
      true
   

 

 
    encodingFilter
    /*
 

 

这个配置要放到其他过滤器的前面,不然有可能会无效

 

 

3修改应用容器tomcat的conf下的server.xml文件

比如我使用的80端口,找到80端口的配置,加上useBodyEncodingForURI="true",修改后如下

 

希望大家关注我一波,防止以后迷路,有需要的可以加群讨论互相学习java ,学习路线探讨,经验分享与java求职      群号:721515304

 

你可能感兴趣的:(java基础)