zoukankan      html  css  js  c++  java
  • Struts2的中文乱码解决

    中文乱码问题一般是指当请求参数有中文时,无法在Action中得到正确的中文。Struts2
    中有2种办法可以解决这个问题:
      设置JSP页面的pageEncoding=”utf-8”,就不会出现中文乱码;
      如果JSP 页面的pageEncoding=”GBK”,那么需要修改struts.i18n.encoding=GBK,在
    struts.xml中加入如下语句进行修改。 

    <?xml version="1.0" encoding="UTF-8" ?> 
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd"
    >
    <struts>
    <constant name="struts.i18n.encoding" value="GBK"/>
    ……
    </struts>

      上面2种方法可以解决POST请求中的中文参数,但是GET请求中的中文参数不能解
    决,GET请求中的中文参数的乱码需要通过修改Tomcat的server.xml文件来解决,修改如
    下内容,加入URIEncoding=”GBK”:

    <Connector port="8080"  …… URIEncoding="GBK"/> 
  • 相关阅读:
    S3:代理模式 Proxy
    S2:外观模式 Facade
    S1:适配器 Adapter
    C5:单例模式 Singleton
    C4:原型模式 Prototype
    C3:建造者模式 Builder
    C2:抽象工厂 Abstract Factory
    C1:工厂模式 Factory
    设计模式分类
    数据访问对象模式
  • 原文地址:https://www.cnblogs.com/winxiang/p/2388210.html
Copyright © 2011-2022 走看看