Solution to garbled Chinese Images uploaded by JSP FCKeditor
Source: Internet
Author: User
After I modified connectorservlet. Java and simpleuploaderservlet. Java two files, regenerate the fckeditor-java-2.3.jar package, to solve all the garbled problem, there are three to modify
1. modify the character encoding of the Web Container. If the Web Container uses tomcat, modify CONF/server. in the XML file, add "uriencoding =" UTF-8 "to the two ctor ins. I use UTF-8 encoding here, So modify it to UTF-8. If the project is gb2312 encoding, set it to "uriencoding =" gb2312 "".
2. when uploading files on the Browser Server Page, open the file/Editor/filemanager/Browser/default/frmupload.html in the project webroot, and add a Meta In the head :, check whether the file is in UTF-8 format. If not, convert it to UTF-8. If you are not using UTF-8, convert it to the encoding you are using. The charset above is also set to the encoding you are using.
3. modify connectorservlet. java and simpleuploaderservlet. java files. I have added a static variable encoding and Private Static string encoding to both files. Save the encoding in the project. if this variable is not passed in the XML file, the default value is gb2312, as shown below: Code If (encoding. isempty () {encoding = "gb2312";}, in connectorservlet. add request to the beginning of doget and dopost in Java. setcharacterencoding (encoding); sets the encoding of the requested character set to the encoding in the project. java and simpleuploaderservlet. in the two java files, diskfileupload upload = new diskfileupload () is added. setheaderencoding (encoding); tells the fileupload component to encode the project during processing. In fileitem, use getstring (encoding). This setting can solve the problem that the obtained form fields are garbled, therefore, getstring (encodin G), it tells fileitem that the encoding used in the value is the encoding set by encoding. For example, in connectorservlet. java and simpleuploaderservlet. the fileitem item in the two java files is followed by an item. getstring (encoding); add an uplfile after the fileitem uplfile. getstring (encoding); set the web. XML. in XML, the preceding encoding value is passed as follows:
<Init-param>
<Param-Name> encoding </param-Name>
<Param-value> UTF-8 </param-value>
</Init-param>
Everything is okay, which truly solves the problem of garbled Chinese name images uploaded.
In the above step 3rd, to use ant to generate jar, then pay attention to, the tomcat installation directory/Server/lib in the catalina-ant.jar copy to the project/WEB-INF/lib. Open build. xml and modify property name = "Catalina. Home" to the tomcat installation directory. Modify taskdef name = "deploy", taskdef name = "list", taskdef name = "reload", taskdef name = "undeploy" as follows:
<Taskdef name = "deploy" classname = "org. Apache. Catalina. Ant. deploytask">
<Classpath refID = "compile. classpath"> </classpath>
</Taskdef>
<Taskdef name = "list" classname = "org. Apache. Catalina. Ant. listtask">
<Classpath refID = "compile. classpath"> </classpath>
</Taskdef>
<Taskdef name = "reload" classname = "org. Apache. Catalina. Ant. reloadtask">
<Classpath refID = "compile. classpath"> </classpath>
</Taskdef>
<Taskdef name = "undeploy" classname = "org. Apache. Catalina. Ant. undeploytask">
<Classpath refID = "compile. classpath"> </classpath>
</Taskdef>
Then run ant's Dist in eclipse's outline window to generate a new FCKeditor-2.3.jar. It is absolutely true. Share it with you. If you upload another file, such as rar, you can share it with anyone who has added this function.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.