Struts2 国际化字符串 拦截器
文件的国际化字符串中使用OGNL,格式为${表达式},例如: validation.required=${getText(fileName)} is required 2. 使用java.text.MessageFormat中的字符串格式,格式为{ 参数序号(从0开始), 格式类形(number | date | time | choice), 格式样式},例如: validation.between=Date must between {0, date, short} and {1, date, short} 加参数的方法:(已核实) <s:text name="validation.required" > 人心的功能,如将Action输出到FreeMaker模板、Velocity模板、JasperReports和使用XSL转换等。这些都过result里的type(类型)属性(Attribute)定义的。另外,您还可以自定义result类型。 下面让我们来做一个Velocity模板输出的例子,首先在classes/struts.xml中新建一个Action映射(Mapping),将其result类型设为velocity,如以下代码所示: <action name="VMHelloWorld" class="tutorial.HelloWorld"> <result type="velocity">/HelloWorld.vm</result> </action> 例3 classes/struts.xml中VMHelloWorld Action的配置 新建HelloWorld.vm,内容如下所示: <html> <head> <title>Velocity</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <h2>Message rendered in Velocity: $message</h2> </body> </html> struts-dojo-tags
- 小蜗牛12015-07-14一点用也没有,纯粹教学,为什么java web项目实现中英文切换没有人来真正实现一下。
- 粉丝: 0
- 资源: 11
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助