0

how to configue the button for upload to support the Chinese character

asked 2011-12-02 03:15:18 +0800

fun gravatar image fun
3

how to configue the button for upload to support the Chinese character?
I use the button to upload file,but when the file name include Chinese character, after uploaded the file name changes to unrecognized character.
Is there a way to solve the problem?

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2011-12-08 03:54:16 +0800

lovetide gravatar image lovetide
169 1 7

it's more like a server config problem. i can get Chinese file name correctly when using Fileupload.

if you're using Tomcat, you need config server.xml and/or web.xml like the following

liu.yan@liuyan /cygdrive/c/tomcat7/conf
$ colordiff -u server.xml.original server.xml

--- server.xml.original 2011-11-20 19:38:06.000000000 +0800
+++ server.xml  2011-11-30 17:26:18.126500000 +0800
@@ -67,9 +67,10 @@
          APR (HTTP/AJP) Connector: /docs/apr.html
          Define a non-SSL HTTP/1.1 Connector on port 8080
     -->
-    <Connector port="8080" protocol="HTTP/1.1"
-               connectionTimeout="20000"
-               redirectPort="8443" />
+    <Connector port="8080" protocol="HTTP/1.1"
+               connectionTimeout="20000"
+               redirectPort="8443" URIEncoding='UTF-8' />
+
     <!-- A "Connector" using the shared thread pool-->
     <!--
     <Connector executor="tomcatThreadPool"
@@ -88,7 +89,7 @@
     -->

     <!-- Define an AJP 1.3 Connector on port 8009 -->
-    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
+    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding='UTF-8' />


     <!-- An Engine represents the entry point (within Catalina) that processes


liu.yan@liuyan /cygdrive/c/tomcat7/conf
$ colordiff -u web.xml.original web.xml
--- web.xml.original    2011-11-20 19:38:06.000000000 +0800
+++ web.xml     2011-11-30 17:26:30.579625000 +0800
@@ -347,6 +355,21 @@
 -->


+    <!-- Example filter to set character encoding on each request -->
+    <filter>
+        <filter-name>Set Character Encoding</filter-name>
+        <filter-class>filters.SetCharacterEncodingFilter</filter-class>
+        <init-param>
+            <param-name>encoding</param-name>
+            <param-value>UTF-8</param-value>
+        </init-param>
+    </filter>
+    <filter-mapping>
+        <filter-name>Set Character Encoding</filter-name>
+        <url-pattern>/*</url-pattern>
+               <dispatcher>REQUEST</dispatcher>
+    </filter-mapping>
+
   <!-- ================ Built In Servlet Mappings ========================= -->


btw, please modify your question title to make it clear

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-12-02 03:15:18 +0800

Seen: 209 times

Last updated: Dec 08 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More