After using liferay for a period of time, it was the first major problem in Chinese. It is said that the author is a chinese. Why didn't he consider Chinese compatibility?
The most direct problem is its Chinese translation. It seems that the author does not understand Chinese, but it also needs to rely on translation software to help translate Simplified Chinese and Traditional Chinese, sentences are literally translated by words in the English Order. This must have been modified one by one, with a heavy workload.
The following lists the program bugs caused by Chinese characters.
Liferay version: 4.1.2
1. The title of the Portlet.
If you change the title of A Portlet to Chinese, garbled characters will appear.
The reason is that liferay saves the property information of the Portlet to the database in XML format, but no format encoding is specified when the XML document is built, resulting in garbled Chinese characters.
Solution: Modify the toxml () method of COM. liferay. Portlet. portletpreferencesserializer
Bytearrayoutputstream baos = new bytearrayoutputstream ();
Xmlwriter writer = new xmlwriter (baos, outputformat. createcompactformat ());
Change
Bytearrayoutputstream baos = new bytearrayoutputstream ();
Outputformat format = outputformat. createcompactformat ();
Format. setencoding ("GBK ");
Xmlwriter writer = new xmlwriter (baos, format );
2. content management.
Content management is the most important Portlet for portal creation. The liferay website is also built using the liferay portal. This website is a good example of how to use liferay to create a portal. After studying this website, we found that both structure and template are used for Journal content, which is helpful for building a wide array of journal content. However, if we use structure and template to create our own journal content, Chinese characters will become garbled again.
Cause: this problem is similar to the first one and also related to XML. If the structure and template are used, liferay writes the text content to the XML of the structure and template, and then stores them in the database. The difference from the first one is that the former requires format data before persistence, and here we need to set encoding when reading data.
Solution: Modify the transform () of COM. liferay. Portlet. Journal. util. journalxslutil. The function of this method is to convert XML into HTML that can be displayed on the page. Add the last line
Return outputbaos. tostring ();
Change
Return outputbaos. tostring ("UTF-8 ");
At this time, the "unhandled exception type unsupportedencodingexception" error will be reported. You can use try catch to process it.
3. RSS
Liferay's message boards provides the RSS function. clicking the RSS icon ie on the Right of category will open the XML page, but if the XML contains a Chinese page, an error will be reported. The original liferay encoding when generating XML files is set to "UTF-8", and if XML contains Chinese, XML file encoding must be set to "GBK" to open normally.
The solution is to change encoding = "UTF-8" to encoding = "GBK", there are multiple modifiable classes, I tend to modify in the outermost layer, So modify COM. liferay. portlet. messageboards. action. the getrss () method of rssaction.
Return RSS. getbytes ();
Change
RSS. replacefirst ("UTF-8", "GBK"). getbytes ();
Another problem is platform relevance. liferay has fewer Chinese problems in Linux than WINXP (not tested in other environments ). For example, when uploading Chinese attachments, I cannot upload attachments with Chinese file names in WINXP, But I can deploy them in Linux. Therefore, it is recommended that liferay be run in Linux.
These problems have been discovered, and problems have been fixed one after another.