使用了ResourceBundle后springboot的配置不生效

xwn_2016 2017-11-06 04:34:11
项目使用springboot
在整合sitemesh3时,遇到了问题,我把过滤路径配置在.properties文件中,通过ResourceBundle去读取时,过滤器无效过,而我在过滤器类中直接写死,却能得到正确的结果,请教一下大神,我这是什么原因?
如果用注释这行,则没问题
	@Override
protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
String contextPath = PropertyUtil.getPropertyByKey("sitemesh.contentPath");
String decoratorPath = PropertyUtil.getPropertyByKey("sitemesh.decoratorPath");
builder.addDecoratorPath(contextPath, decoratorPath);
// builder.addDecoratorPath("/sitemesh/*", "/sitemesh/index");
builder.addExcludedPath("/admin/*");
builder.addExcludedPath("/sitemesh/index");
}


constant.properties文件
#sitemesh
sitemesh.contentPath = "/sitemesh/*"
sitemesh.decoratorPath = "/sitemesh/index"
sitemesh.excludedPaths ="/js/*,/css/*,/admin/*,/sitemesh/index"


PropertyUtil.java类
public static String getPropertyByKey(String key) {
String value = "";
Locale locale = Locale.getDefault();
try {
ResourceBundle localResource = ResourceBundle.getBundle("constant",locale);
value = localResource.getString(key);
} catch (MissingResourceException mre) {
value = "";
mre.printStackTrace();
// LoggerUtil.logger.error("=====配置文件constant.properties文件没找着",mre);
}
return value;
}
...全文
685 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xwn_2016 2017-11-08
  • 打赏
  • 举报
回复
引用 4 楼 java_augur 的回复:
用system.out.println打出来看看

java_augur 2017-11-08
  • 打赏
  • 举报
回复
用system.out.println打出来看看
xwn_2016 2017-11-08
  • 打赏
  • 举报
回复
望大家多支持一下
xwn_2016 2017-11-07
  • 打赏
  • 举报
回复
引用 1 楼 java_augur 的回复:
首先看两个值是否取到,如果取到看看“/”是不是在取值过程中被过滤掉了,如果被过滤,前面再多加一个“/”,另外要考虑’“‘是不是被过滤掉了?
启动时debug看到的和直接写死的一样样的
java_augur 2017-11-06
  • 打赏
  • 举报
回复
首先看两个值是否取到,如果取到看看“/”是不是在取值过程中被过滤掉了,如果被过滤,前面再多加一个“/”,另外要考虑’“‘是不是被过滤掉了?

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧