Method of using Displaytag to make column names appear in Chinese

Source: Internet
Author: User
Tags copy execution resource tld
Show | Chinese recently used exadel add eclipse to do a struts project, the result encountered many problems, one of the important problem is the culture of the problem, this problem in many places have met, the following will introduce a method, You can make the report column names produced by Displaytag into Chinese.

The first step is to add Jstl FMT support to the Web page.

1, will jstl need Jstl.jar and Standard.jar copy to the Webcontent\web-inf\lib directory
2, copy the FMT.TLD to the Web-inf directory
3, modify the Web-inf directory of the Web.xml file, add the following line to the corresponding position
<taglib>
<taglib-uri>/WEB-INF/fmt</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
4. Add <%@ taglib uri= "/web-inf/fmt.tld" prefix= "FMT"%> to support FMT on the header of the JSP file to be edited

The second step is to include support for resource files in the system

1, in any package below the Javaresoruce directory (the following is assumed to be a sample package) to create a resource file, named Test.properties
2, enter the following line of content test
test= Chinese Content
3, in the sample directory below create a bat file, named Encode.bat, edited as follows
%java_home%\bin\native2ascii-encoding gb2312 test.properties test_zh.properties
And then save the exit
4, double click on this bat file execution, after execution will generate a name called Test_zh.bat file
5, in the Struts-config.xml file <controller/> after adding the following line of content
<message-resources parameter= "Sample.test.properties"/>
6, in the need to edit the JSP file to edit the following, which Titlekey is the key
<fmt:bundle basename= "Sample.test_zh" >
<display:table...>
<display:column property= "name" <b>titlekey= "test" </b> headerclass= "sortable"/>
</display:table>
</fmt:bundle>

So the Displaytag column name shows "Chinese content":

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.