开发者

Is it possible to use EL inside page directives?

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" />
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜