开发者

Alter translations in jstl fmt without recompile

开发者 https://www.devze.com 2023-04-11 09:49 出处:网络
I\'m currently working on an internationalized webapplication in java, using only the standard servlet api (no frameworks). for all static text on the pages like headings, labels etc. I\'ve been using

I'm currently working on an internationalized webapplication in java, using only the standard servlet api (no frameworks). for all static text on the pages like headings, labels etc. I've been using the fmt tag library, backed by properties files in WEB-INF/classes. the application is almost done, but the requirement that our client might like to change or update the translations lat开发者_运维知识库er on, has suddenly been introduced.

Since the properties files are located inside the war, this is not doable without recompiling the app. so, my question is simply: is there any way of updating the properties files inside the war or maybe have the setBundle tag load the files from an external directory. or maybe a third, more clean and correct way to achieve this?


A war is just a zip file. Unzip it, change the properties files, and rezip. No need to recompile anything.

Providing a simple script to do that in a single operation should be easy. You could even use the u (update) option of jar to do it. See http://download.oracle.com/javase/tutorial/deployment/jar/update.html


Put them in an external folder and add its path to the webapp's runtime classpath. For example, /var/webapp/conf. As to adding this path to the webapp's runtime classpath, this depends on the server used. If it's for example Tomcat 6/7, then you need to add it to the shared.loader property of Tomcat/conf/catalina.properties file.

shared.loader = /var/webapp/conf

This way it's available in webapp's runtime classpath the usual way and you don't need to repackage the WAR..

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号