I have some static html content (included on a dynamically generated page) that I want to localize, i.e., help-en.html, help-fr.html and so on. In the JSP file where it is to be included I have a bean userLocale which is a string containing "en", "fr" and so on.
Thus a reasonable way to refer to the localized file would be:
help-${userLocale}.html
And a reasonable w开发者_StackOverflow社区ay to include it into the JSP would be:
<%@include file="help-${userLocale}.html" %>
However, this does not work, as the JSP compiler complains that it cannot file the file literally named "help-${userLocale}.html". Thus it seems that page directives are processed before EL code, and as such it's not possible to use EL inside page directives.
Is this correct, are there any workarounds, and/or are there any similarly simple ways to achieve the goal described above, without resorting to multiple choose/when tags or whatnot?
Use jsp:include
instead. The @include
is compiletime, not runtime.
E.g.:
<jsp:include page="help-${userLocale}.html" />
精彩评论