简体   繁体   中英

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

In my webapp, 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?

还有一个=落后太多scope

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM