org.springframework.context.support
Class ResourceBundleMessageSource
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 asorg.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. -
注意上面加大并加下划线的文字, "注意ResourceBundle的名字要是有效的类路径",所以message.properties等需要用ResourceBundle载入的文件不能放在src目录之外。