zoukankan      html  css  js  c++  java
  • 传值乱码解决方案

    1、在web.xml中配置编码方式


    <!-- spring Web MVC框架提供了org.springframework.web.filter.CharacterEncodingFilter用于解决POST方式造成的中文乱码问题 -->
    <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>
    </filter>
    <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- 处理中文乱码问题 start
    <filter>
    <filter-name>UTF-Encoding</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>
    </filter>

    <filter-mapping>
    <filter-name>UTF-Encoding</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping> -->

    2)接收的地方在上编码方式

    request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");

    3)在tomcat中server.xml的端口号后面加上

    <Connector connectionTimeout="20000" port="8081" protocol="HTTP/1.1" redirectPort="8443" URIEncoding ="UTF-8"/>

    4)热部署下ajax传值乱码

    <configuration>
    <port>8088</port>
    <path>/</path>
    <uriEncoding>UTF-8</uriEncoding>
    </configuration>

  • 相关阅读:
    用户模版
    VC让对话框显示就最大化
    C#中char[]与string之间的转换
    c#调用C++DLL参数对应
    解决:对 PInvoke 函数的调用导致堆栈不对称问题 <转载>
    git 命令的使用
    me 云面试
    Django 自定义模板语法
    Django session 源码流程
    云计算的介绍
  • 原文地址:https://www.cnblogs.com/joyous-day/p/6142248.html
Copyright © 2011-2022 走看看