当bean中有datetime型的属性时,在网页上格式化输出,以前我是使用工具类的静态方法进行转换。现在发现了struts自已有更简单的处理办法,如下:
1.在资源文件里添加如下键值(我使用IBM的工具RbManger,很好用的):
global.formatDateTimeAll=yyyy年MM月dd日 HH:mm:ss
global.formatDateTime=yyyy年MM月dd日 HH:mm
global.formatDate=yyyy年MM月dd日
global.formatMonth=yyyy年MM月
global.formatYear=yyyy年
2.在JSP页面这样写
<bean:write name="xxx" property="createTime" formatKey="global.formatDateTime"/>
from matrix 论坛 struts及mvc framework 版。