struts2警告: The first TextProvider in the ValueStack could not locate the message resource with key
Posted on 2011-09-18 00:19 第二银行 阅读(6592) 评论(0) 编辑 收藏 举报问题描述 : struts2 中,在jsp页面使用<s:text>标签会伴随产生这个警告
解决过程:查看官方API关于这个标签的描述。
地址:http://struts.apache.org/2.0.14/docs/text.htm
Description
Render a I18n text message.
The message must be in a resource bundle with the same name as the action that it is associated with.
(这个消息必须与action同名资源文件捆绑使用)
In practice this means that you should create a properties file in the same package as your Java class with the same name as your class, but with .properties extension.(在使用过程中应该在java类同一个包下创建一个同名的属性文件,其扩展名为.properties )
If the named message is not found, then the body of the tag will be used as default message. If no body is used, then the name of the message will be used.
For more details on using resource bundles with Struts 2 read the localization guide.
Parameters
Name |
Required |
Default |
Evaluated |
Type |
Description |
---|---|---|---|---|---|
id | false | false | String | Deprecated. Use 'var' instead | |
name | true | false | String | Name of resource property to fetch | |
var | false | false | String | Name used to reference the value pushed into the Value Stack |
上面的意思是 name是必须的有的标签,id和var不必须有,其中id 标签已经废弃,已经使用var替代id。
解决办法:
在action文件下创建同名资源文件,并定义i18n属性,例如 “user = 用户”