I18N modification(1)

There is a bean set in xml, and has a method called getAllShareScopes which return a collection has a map of select element.

I found the getAllShareScopes method is simple, just return allShareScopes.

So where and when dose it get the value?

I found afterPropertiesSet methods, and knew the allShareScopes get value there.

And what's new to me is that, the afterPropertiesSet methods is invoked when the service is started, that is to say, when the server starts, the settings in xml files will be setted, and all the values may be stored in application!

 

The I18N work seems to be done when the server starts:

 

ctx.getMessage(scope.getLabelKey(), null, Locale.getDefault());

 

It's absolutely wrong, because we should get the client locale instead of the server's locale.

So the I18N work shouldn't be done here.

What we can do here is fetch the key value: String label = scope.getLabelKey();

Then do the i18n work in jsp file like:

 <c:forEach var="scope" items="${allShareScopes}">
         <option value="${scope.name}"><fmt:message key="${scope.label}"/></option>
 </c:forEach>

 

This may be simple to others, but I learnt some from the research and fixing, so I record it.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值