Language selection in the combo


I configured my servlet to support internationalization, just as I showed below:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basename" value="classpath:messages" /> <property name="defaultEncoding" value="UTF-8"/> </bean> <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="lang" /> </bean> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"> <property name="defaultLocale" value="en"/> </bean> <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> <ref bean="localeChangeInterceptor" /> </property> </bean>

On the JSP page, I added the choice of language in such a way:

<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <h3><spring:message code="label.title"/></h3> <span style="float: right"> <a href="?lang=en">en</a> | <a href="?lang=de">de</a> </span>

How do I replace the above code component of a select (combo)?

(pseudo code)

<td><form:select path="language" onchange=""> <form:option value="0" label="..." /> <form:options items="${languageList}" /> </form:select></td>

Please help

EDIT I do not want anything to set as the default. He wants to be chosen this option, he chose you. You will see an example:

The first step localhost: 8080/newUser -> In controller

@ RequestMapping (value = "/ newuser" method = RequestMethod.GET) public ModelAndView showNewUser (ModelMap model) { ModelAndView mav = new ModelAndView (); mav.mav.setViewName ("newuser"); User user = new User (); mav.getModel (). put ("user", user); return mav;

My JSP forms ...

<form id="langForm" action="newUse" method="get"> <table> <tr> <td> <a href="#"> <spring:message code="label.helpLink" /> </ a> </ td> <td> <select name="lang" id="lang"> <option value="de"> <spring:message code="languageName.de"> </ spring: message> </ option> <option value="en"> <spring:message code="languageName.en"> </ spring: message> </ option> </ select> </ td> </ tr> </ table> </ form>


<script type="text/javascript"> $ ("# lang"). change (function () { document.forms ["langForm"] submit (); }); </ script>

The second step - End-user selects from the combo options "languageName.en. Followed by reloading the page (localhost: 8080/newUser? lang = en) to change the language to EN but the combo is still selected as the first item. I would like to chose was the one you selected in step 2 So, I would save the state.


<form> <select name="lang" id="lang" onchange="this.form.submit();"> <option value="pl"><spring:message code="languageName.pl"></spring:message></option> <option value="en"><spring:message code="languageName.en"></spring:message></option> </select> </form>

How to keep the option without a model?


in jsp

<form:select path="language" onchange=""> <c:forEach var="lan" item="${languageList}"> <form:option value="0" label="${lan}" /> <form:options items="${lan}" /> <c:forEach /> </form:select>

add javascript that will listen to its change in state. if change occurs reflect this param language in session


Suppose you have combo box like this

<select> <option>Small</option> <option>Medium</option> <option>Large</option> <option>X-Large</option> </select>

and you want X-large to be selected by default, make HTML like this

<select> <option>Small</option> <option>Medium</option> <option>Large</option> <option selected="true">X-Large</option> </select>

make it

<select name="lang" id="lang"> <option value="de" <c:if ${sessionBean.lan}=='de'>seelcted='true'</c:if>> <spring:message code="languageName.de"> </ spring: message> </ option> <option value="en" <c:if ${sessionBean.lan}=='en'>seelcted='true'</c:if>> <spring:message code="languageName.en"> </ spring: message> </ option> </ select>


  • font-face not showing up on Firefox
  • Use Greasemonkey to remove table
  • AngularJS error injector modulerr
  • How can I have equal heights for inner elements of flexbox grid/boxes/cards without using jQuery?
  • MySQL multiple IN conditions to subquery with same table
  • Search files(key) in s3 bucket takes longer time
  • What does Main.1 output file do in XCode?
  • Create registry key in 32-bit hive on x64 PC using Installshield 2012 LE - Avoid redirection
  • Configuring multiple DefaultJmslistenercontainerfactory
  • Is it possible to get the word under the mouse cursor in a ``?
  • BeautifulSoup difference between findAll and findChildren
  • NHibernate manually control fetching
  • JPA flush vs commit
  • xcode don't localize specific strings
  • Validate child input components on submit with Vee-Validate and vue js 2
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • What is the purpose of TaskExecutor in spring?
  • Swift: Switch statement fallthrough behavior
  • NHibernate Validation Localization with S#arp Architecture
  • How can I send an e-mail from a vbs script
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Optimizing database types to compact database (SQLite)
  • Accessing IRQ description array within a module and displaying action names
  • Cross-Platform Protobuf Serialization
  • htaccess rewriting URLs with multiple forward slashes
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • Do I've to free mysql result after storing it?
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • A cron job substitute?
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Getting Messege Twice Using IMvxMessenger
  • Turn off referential integrity in Derby? is it possible?
  • How can I remove ASP.NET Designer.cs files?
  • JaxB to read class hierarchy
  • java string with new operator and a literal