There is such a task. There is a JSP page that should be configured based on the user's language. With the definition of language issue resolved. A certain array with the meanings of word variations has been created. How to transfer a lot of values for the minimum number of actions from a class with an array to a servlet, put everything in its place and only then show the user? For each value, writing request.setAttribute ("var", value) is long, tedious, and probably not justifiably silly. How to implement correctly?
1 answer
There is a way using perperty files. Jstl connects on jsp itself:
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> according to the key, the message is taken out depending on the locale:
<spring:message code="label.message.expired" /> Learn more: http://docs.spring.io/spring/docs/1.2.x/taglib/tag/MessageTag.html
- created files perperti. I define the locale and select the desired file with the values key = parameter.
ResourceBundlepassed throughsession.setAttribute. How to pull in JSP to reach the key? Preferably without spring'a - xrk - can it be easier to do and pass through the session not all together, but only the path to the localization file? On the other hand, in the example in the documentation, all key pairs = value are passed through the session completely. - xrk
- You can create java.util.ResourseBundle on jsp, and remove it in scripts - Uladzislau Kaminski
|