在servlet中加载属性文件? [英] Load properties file in servlet?
本文介绍了在servlet中加载属性文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个java maven项目。我在 src / main / resources
文件夹中放置了一个属性文件。
I have a java maven project. i have placed a properties file in src/main/resources
folder.
src/main/resources
|
|___properties
|
|
|___custom_en_US.properties
我在servlet中加载属性文件如下所示。
I am loading properties file as below in servlet.
ResourceBundle bundle = ResourceBundle.getBundle("classpath:properties/custom", request.getLocale());
但是上面的行正在抛出异常,说资源未找到。我如何提供属性文件的路径?请帮助我。
but above line is throwing exception saying resource not found. How can i give path to properties file? Please help me.
谢谢!
推荐答案
摆脱classpath前缀: .getBundle(/ properties / custom)
Get rid of the "classpath" prefix.: .getBundle("/properties/custom")
classpath前缀是它不是标准,而是由一些框架定义,如spring。
The "classpath" prefix is not a standard, it is defined by some frameworks like spring.
这篇关于在servlet中加载属性文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文