個人檔案最后一块心灵净土,让我们畅所欲言相片部落格清單更多 ![]() | 說明 |
|
6月21日 Struts2、Spring、Hibernate应用总结(一)Struts2
1、自定义类型转换器及自定义类型转换错误的msg:
①局部类型转换器:
创建action名-conversion.properties(如:TestAction-conversion.properties)放到同action相同的目录下,
内容为:要转换的字段名=所使用的转换器(如:beginDate=cn.com.activenetwork.cm.common.util.DateTypeConverter)。
②全局类型转换器:
在同struts.xml同级目录下创建xwork-conversion.properties文件,
内容为:需要转换成的类型=所使用的转换器(如:java.util.Date=cn.com.activenetwork.cm.common.util.DateTypeConverter)。
③自定义类型转换错误msg
局部错误msg:为一个action新建一个properties文件(如:TestAction.java对应TestAction.properties),内容为:invalid.fieldvalue.被转换的字段名=转换失败后的消息。
全局错误msg:在struts2.xml中加入对于国际化的支持<constant name="struts.custom.i18n.resources" value="messageResource(可多个,用“,”分隔)"></constant>,然后在对应语言的国际化消息文件中(例:messageResource_zh_CN.properties)追加内容:invalid.fieldvalue.被转换的字段名 = 日转换失败后的消息。
|
|
|