开发者

How to access variable set by JSTL core in my JSP page?

In my weba开发者_C百科pp, I want to set a default cookie to store a locale of 'en_US'. I have functionality in place for the user to change this successfully.

However, I've removed a lot of scriptlets on my .jsp and replaced with some JSTL tags to set a default cookie value, but it doesn't seem to work. It seems that I can't access my ${lang} variable in my locale declaration. Am I missing something?

Here's my code:

<c:set var="lang" scope=="session">
   <c:out value="${cookie['locale'].value}" default="en_US"/>
</c:set>

<fmt:setLocale value="${lang}" />
<fmt:bundle basename="com.foo.bar.app">

Edit

It seems as though I'm still having a problem. My setLocale call is not getting a good value. I tried a simple <c:out value="${lang}"/> and it is printing out ${lang} rather than a value, so I assume that my locale is being set to the variable name rather than the value. Any idea?


There's one = too much behind scope.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜