<img src="/pic/图片1.jpg"/>
用户上传一张图片 难免出现中文名字,英文正常显示,中文怎么解决?

解决方案 »

  1.   

    设置编码就可以了,gbk或者utf-8
      

  2.   

    在struts.xml配置文件中配置
    <constant name="struts.i18n.encoding" value="GBK"></constant>
    就可以了
      

  3.   

    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    web.xml里面配置一下
      

  4.   

    如果你用 tomcat的话,打开conf/server.xml找到
    <Connector
    port="8080"               maxHttpHeaderSize="8192"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   connectionTimeout="20000" disableUploadTimeout="true"
    URIEncoding="UTF-8" useBodyEncodingForURI="true" />
        <!-- Note : To disable connection timeouts, set connectionTimeout value
         to 0 -->
    加上红色的部分就行了