关于velocity模版通过MessageTool实现国际化i18n的有关问题

关于velocity模版通过MessageTool实现国际化i18n的问题
向个位大神请教。
在做一个国际化的项目,前端页面是使用的hml+velocity实现动态数据展现,没有使用jsp,所以在实现国际化方面没有struts标签来的方便.

在网上查了下使用velocity的MessageTool可以实现struts的国际化这块.

但是,当我配置好之后发现并不能获取到内容,下面是配置文件


<!-- velocity中配置MessageTool -->

<tool>

        <key>message</key>

        <scope>request</scope>

        <class>org.apache.velocity.tools.struts.MessageTool</class>

    </tool>


在html中调用:


<!-- 使用 ${message.get("name")} 相等于 ActionSupport 中的 getText("name")。 -->
国际化:$!{message},${message.get("name")}<br>


运行后第一个结果理所当然是一个内存地址值,而第二个因为取不到值输出了字符串${message.get("name")}.
这个结果实在是让我抓狂了.初步分析,好像是获取不到struts那块的资源文件,但是我在action中使用输出是可以的:

1
public class Test extends ActionSupport{
  
 @Override
 public String execute() throws Exception {
        System.out.println(getText("name"));



这样在控制台是有值输出的。
请教下各位大神:我应该怎样使用velocity实现国际化?
------解决方案--------------------
你要使用org.apache.velocity.tools.generic.ResourceTool这个类,然后配置国际化文件。
------解决方案--------------------
messageResource.xml
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">     
<property name="basenames">
<list>
<value>/WEB-INF/messageResource/MessageResource</value>
                         </list></property>

测试:
private static MessageSource messageSource;
WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
messageSource = (MessageSource) applicationContext.getBean("messageSource");
MessageTool messageTool = new MessageTool(new MessageSourceAccessor(messageSource), locale);
ToolContext context = manager.createContexg
8h"@t();
context.put("messageTool", messageTool);

                System.out.println("-------begin---------");
                System.out.println(messageTool.get("code1"));// hello
                System.out.println("-------end-----------");

message_en_US.properties 例子:
code1=hello
code2=foo {0}

test.vm 例子:
code1: $message.get("code1")
code2: $message.get("code2", ["bar"])
code3: $message.get("code3", "default")

------解决方案--------------------
关于velocity模版通过MessageTool实现国际化i18n的有关问题好深奥。。给你顶一下。