Solution to Eastwood Chinese display garbled problem

[url=http://www.jfree.org/eastwood/]eastwood[/url] is [url=http://code.google.com/intl/zh-CN/apis/chart/]google chart api[ /url] is an open source independent implementation, based on jfreechart. Eastwood eliminates the need to go into the details of plot, Axis, and Renderer when calling jfreechart, and allows you to draw pictures in a simpler and more elegant way.

The default configured eastwood will have Chinese garbled characters. The solution is as follows:

Upgrade jfreechart to 1.0.10 and eastwood to 1.1.0, and then configure them in web.xml
  <servlet>
<servlet-name>chart</servlet-name>
<servlet-class>org.jfree.eastwood.ChartServlet</servlet-class>
<init-param>
<param-name>fontResource</param-name>
<param-value>/WEB-INF/classes/wqy-zenhei.ttc</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>chart</servlet-name>
<url-pattern>/chart</url-pattern>
</servlet-mapping>

The wqy-zenhei.ttc here can be any font file that supports Chinese. I use Wenquanyi.

If you are using tomcat, you need to deal with the get Chinese garbled problem in its server.xml.

For Firefox, this configuration eliminates the problem of Chinese garbled characters, but for IE, Chinese must be encoded in this way.
URLEncoder.encode("费用","utf-8")


ps, eastwood has not released a new version for more than a year. Someone asked if the project was stopped. The answer from the jfreechart developer was sad. A well-known open source project developer still has to work hard to make a living.
[quote]Postby david.gilbert » Tue Jun 23, 2009 10:42 am
It isn't discontinued, just very quiet. There's only been limited interest in the project, and for financial reasons I have had to focus my energies on tasks that generate some income rather than just creating more free stuff. I committed some stuff to Subversion last month, and would like to make a new release of Eastwood some time...but I have another project on right now.[/quote]

Guess you like

Origin blog.csdn.net/fireshort/article/details/83452617