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
ResourceBundleconventions: 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.ResourceBundleusage.
See Also: )]
setBasenames(java.lang.String[]),
ResourceBundle.getBundle(String)
注意上面加大并加下划线的文字, "注意ResourceBundle的名字要是有效的类路径",所以message.properties等需要用ResourceBundle载入的文件不能放在src目录之外。
相关文章推荐
- Spring 加载类路径外的资源文件
- spring-boot 加载本地静态资源文件路径配置
- 【spring boot】3.spring boot项目,绑定资源文件为bean并使用
- spring-boot 加载本地静态资源文件路径配置
- 【spring】ApplicationListener传递参数到页面(解决静态+动态资源路径+静态文件的缓存控制)
- spring boot 加载本地静态资源文件路径配置
- spring-boot 加载本地静态资源文件路径配置
- spring-boot 加载本地静态资源文件路径配置
- Spring 加载类路径外的资源文件
- 将tomcat web项目图片文件资源放在非项目路径下
- spring-boot 加载本地静态资源文件路径配置
- spring-boot 加载本地静态资源文件路径配置
- Spring 获取资源文件路径
- spring-boot 加载本地静态资源文件路径配置
- 【spring】ApplicationListener传递参数到页面(解决静态+动态资源路径+静态文件的缓存控制)
- spring-boot 加载本地静态资源文件路径配置
- spring-boot 加载本地静态资源文件路径配置
- Spring配置文件详解 - applicationContext.xml文件路径
- 【第四章】 资源 之 4.4 Resource通配符路径 ——跟我学spring3
- c# winfrom资源文件的调用和路径全解