John Chang wrote:
> In struts, can I set the language that is to be used
> in a querystring, and then the JSP can display in the
> designed language? How to write tag of
> <bean:message... />? How to set the corresponding
> environment, including properties files, tld files,
> web.xml?
>
You can do this, but indirectly.
The Struts <bean:message> tag bases its language choice on a session
attribute that is stored under key "org.apache.struts.action.LOCALE".
(In a program, you would use the symbolic string constant
Action.LOCALE_KEY for this). So, if you want to switch languages, all
you would need to do is
* Create a new Locale for the desired language
Locale loc = new Locale("fr"); // French
* Store the new Locale under this session attribute key:
HttpSession = request.getSession();
session.setAttribute(Action.LOCALE_KEY, loc);
>From now on, any page that uses <bean:message> will display the French
translation of the messages (and so on, each time you change the
Locale).
>
> Thanks a lot!
>
> John
>
Craig McClanahan