Accessing i18n properties file from “webcontent” or “WEB-INF\local” folder

断了今生、忘了曾经 提交于 2020-01-06 07:54:45

问题


I am developing a JSP / Servlet pages which needs to be i18n. The example codes which I have seen on the internet are using JSTL's setlocal and setbundle tags. And they are adding the .properties file in the java source folder or WEB-INF\classes folder.

I am using Apache Tomcat 6.0.32 and JSTL1.2 jar files for the project.

I wanted to know can we added the .properties file in say webcontent\i18n or WEB-INF\local folder. And access it using JSTL tags?


回答1:


It has to go in the classpath. They're under the covers loaded by ResourceBundle which loads them by default form the classpath. So, putting it outside the classpath won't work. You can always put them in a (sub)package like so /WEB-INF/classes/local/filename.properties. You should then only access it with basename local.filename instead of filename.

See also:

  • How to internationalize a Java web application?


来源:https://stackoverflow.com/questions/10653742/accessing-i18n-properties-file-from-webcontent-or-web-inf-local-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!