Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4608248
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:49:05+00:00 2026-05-22T00:49:05+00:00

I have the following form. <form id=langForm action= method=get> <select name=lang id=lang class=styled onchange=this.form.submit();>

  • 0

I have the following form.

<form id="langForm" action="" method="get">
    <select name="lang" id="lang" class="styled" onchange="this.form.submit();">
        <option value="pl" ${param.lang == 'pl' ? 'selected' : ''} >PL</option>
        <option value="en" ${param.lang == 'en' ? 'selected' : ''} >EN</option>
    </select>
</form>

Spring MVC sets the language parameter and takes care about i18n/l10n. I would like to change the ${param.lang} to let it obtain the current user language from session by Spring MVC, because the lang parameter is not necessarily present in every request. How can I achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:49:06+00:00Added an answer on May 22, 2026 at 12:49 am

    Add the fallowing in your xml configuration:

    ...
    
    <mvc:interceptors>
            <bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" />
            <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
                p:paramName="lang" />
        </mvc:interceptors>
    
    <bean id="messageSource"
            class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename" value="classpath:messages" />
            <property name="defaultEncoding" value="UTF-8" />
        </bean>
        <bean class="org.springframework.web.servlet.i18n.CookieLocaleResolver"
            id="localeResolver" p:cookieName="locale" />
    ...
    

    Replace you code by:

    <form id="langForm" action="" method="get">
        <select name="lang" id="lang" class="styled" onchange="this.form.submit();">
            <option value="pl">PL</option>
            <option value="en">EN</option>
        </select>
    </form>
    

    With this configuration the locale selected wil be save in cookies browser.

    don’t forget namespaces at the begin of file in tag :
    xmlns:mvc=”http://www.springframework.org/schema/mvc”
    and

    xsi:schemaLocation=”http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

    tutorial here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form from http://regain.sourceforge.net/ : <form name=search action=search.jsp method=get> <p class=searchinput>
I have the following form <form name=myForm id=myForm method=post enctype=multipart/form-data action=script.php> and this jQuery
I have the following form: <form action=download.php method=get> <input type=checkbox name=file1 /> File1 <br/>
I have the following form: <form action= method=get> <input name=form1 type=radio onclick=document.forms[0].testbox.value='0.00'; /> <input
i have the following form <form action=ManageLink method=post> <input name=artistName type=text/> <input name=songName type=text/>
I have following html form: <form method=post action=> <input type=hidden name=userid id=user value=<?php echo
I have the following form that has 2 selects: <form id=form class=form_visitar method=post action=ajax/selects.php>
I have the following form: <form action=post.php method=POST> <fieldset> <div class=ratingClass> <input type=radio class=radio
I have following form. <form action= method=post id=save-user> <button type=button name=save-user>Save</button> <button type=button name=save-user-close>Save
I have the following form. <form name=cookieform id=login method=POST> <input type=text NAME=username id=username class=text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.