您的位置:首页 > 编程语言 > Java开发

Spring的资源绑定的文件要放在类路径里

2008-04-16 16:25 302 查看


[title2]org.springframework.context.support
Class ResourceBundleMessageSource[/title2]

setBasename

public void setBasename(String basename)

Set a single basename, following
ResourceBundle
conventions: essentially, a fully-qualified classpath location. If it doesn't contain a package qualifier (such as
org.mypackage
), it will be resolved from the classpath root.
Messages will normally be held in the "/lib" or "/classes" directory of a web application's WAR structure. They can also be held in jar files on the class path.

Note that ResourceBundle names are effectively classpath locations: As a consequence, the JDK's standard ResourceBundle treats dots as package separators. This means that "test.theme" is effectively equivalent to "test/theme", just like it is for programmatic
java.util.ResourceBundle
usage.


See Also: )]
setBasenames(java.lang.String[])
,
ResourceBundle.getBundle(String)

注意上面加大并加下划线的文字, "注意ResourceBundle的名字要是有效的类路径",所以message.properties等需要用ResourceBundle载入的文件不能放在src目录之外。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: