它是提供显示“本地化”支持的:
<bean:write>
In the Struts 1.1 release, <bean:write> gained the format property. This provides a
way to apply a standard formatting template against the value being written:
<bean:write name="inputForm" property="amount" format="$#.##"/>
A formatKey property is provided that reads the template from the resource bundle:
<bean:write name="inputForm" property="amount" formatKey="pattern.currency"/>
A locale property is also provided if another Locale object is to be used instead of
the framework’s default. The locale property indicates the name of a sessionscope
attribute:
<bean:write name="inputForm" property="amount" formatKey="pattern.currency"
locale="myLocale"/>
STRUTS TIP Don’t use custom tags to format data. Instead, localize data inside an ActionForm
or (even better) on the business tier. You can easily pass the
Struts Locale object to the ActionForm (or your business bean) and apply
the localization in the getter. To store the user’s Locale object in your ActionForm,
add a locale property and put this code in the reset method:
HttpSession session = request.getSession();
if (session!=null) {
setLocale((Locale)
session.getAttribute(Action.LOCALE_KEY));
}
else {
setLocale(Locale.getDefault());
}我觉得你不必这么做。actionform里的属性可以完全用string,不必使用 int型或其它
<bean:write>
In the Struts 1.1 release, <bean:write> gained the format property. This provides a
way to apply a standard formatting template against the value being written:
<bean:write name="inputForm" property="amount" format="$#.##"/>
A formatKey property is provided that reads the template from the resource bundle:
<bean:write name="inputForm" property="amount" formatKey="pattern.currency"/>
A locale property is also provided if another Locale object is to be used instead of
the framework’s default. The locale property indicates the name of a sessionscope
attribute:
<bean:write name="inputForm" property="amount" formatKey="pattern.currency"
locale="myLocale"/>
STRUTS TIP Don’t use custom tags to format data. Instead, localize data inside an ActionForm
or (even better) on the business tier. You can easily pass the
Struts Locale object to the ActionForm (or your business bean) and apply
the localization in the getter. To store the user’s Locale object in your ActionForm,
add a locale property and put this code in the reset method:
HttpSession session = request.getSession();
if (session!=null) {
setLocale((Locale)
session.getAttribute(Action.LOCALE_KEY));
}
else {
setLocale(Locale.getDefault());
}我觉得你不必这么做。actionform里的属性可以完全用string,不必使用 int型或其它
解决方案 »
- 在公司里大家是如何缩进代码的?
- struts的小问题
- 又被打击了 散点分 缓解一下心理压力
- hibernate中的SessionFactory,Session分别表示什么啊?如何理解?
- 本人想找个JAVA(J2EE方向)的老师。(工作地点在西安的,晚上有时间的)
- hibernate多表连接查询问题
- struts循环的问题
- 请教(急需外文资料)
- 新手上路:到底什么是EJB?有什么用?它和中间件有什么关系?
- visaulage for java的ejb的开发和测试环境
- jsp+tomcat+mysql调试问题
- struts 一个form,两个submit,结果不同action在获取表单表单数据时(debug),发现提示:can not locate requestFacade.java from project cl
我用过日期和浮点型的格式化。