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 7918259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:26:33+00:00 2026-06-03T15:26:33+00:00

I have been scratching my head over an encoding problem with a Tomcat web

  • 0

I have been scratching my head over an encoding problem with a Tomcat web application built with Spring MVC 3.1.1.

The Problem

Form input field value bound by spring via Freemarker Spring macro gets decoded as ISO-8859-1 instead of UTF-8.

Current Configuration

I have configured freemarker to encode everything in UTF-8.

    <bean id="freemarkerConfig"
       class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
       <property name="templateLoaderPath" value="/WEB-INF/templates/" />
       <property name="freemarkerSettings">
          <props>
            <prop key="auto_import">spring.ftl as spring</prop>
            <prop key="url_escaping_charset">UTF-8</prop>
          </props>
       </property>
    </bean>

Here is my character encoding filter setup in the web.xml file.

<filter>
   <filter-name>characterEncodingFilter</filter-name>
   <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
   <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
   </init-param>
   <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
   </init-param>
</filter>

<filter-mapping>
   <filter-name>characterEncodingFilter</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>

HTML markup head tag contains:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

UTF-8 encoding works great for displaying data that comes back in my freemarker views, with the exception of data that is bound to form values such as the input below.

<form id="main-search-form" action="search" method="GET">
   <@spring.formInput 'searchForm.q' 'id="q" maxlength="2048" autocomplete="off" spellcheck="false"'/>
</form>

As far as I can tell, and after doing hours of reading on the internet, it seems like Spring defaults to ISO-8859-1 in most cases, but I have not found a bean to override to change the type of decoding for bound data. Even when the HTTP request is encoded in UTF-8 and the tomcat container’s Connector node is set with URIEncode=”UTF-8″, Spring tries to decode with ISO-8859-1.

Any help would be appreciated.

  • 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-06-03T15:26:36+00:00Added an answer on June 3, 2026 at 3:26 pm

    After banging my head on my desk for hours, I think I finally figured out what the problem was. My configurations above were all correct (including the Tomcat connecter property, URIEncode=”UTF-8″).

    I made the mistake of assuming that it was Spring MVC that was handling the encoding of my GET requests via a form submit.

    However, it was really just a problem with the form markup. I needed to specify that the form charset as UTF-8.

    <form id="main-search-form" action="search" method="GET" accept-charset="UTF-8"> 
       ...
    </form>
    

    This, in combination with the above configurations, resolved my problem.

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

Sidebar

Related Questions

I've been scratching my head over this for an hour... I have a list
I have been scratching my head over this for days and I still cannot
I have a problem which I've simplified down and have been scratching my head
I have been scratching my head for sometime know to get my problem sorted
I dont know the exact problem but have been scratching my head for almost
Okay guys, I have been scratching my head like mad over this issue and
Been scratching my head for a day over this one. I have a few
I have been scratching my head for a while on this one. I dont
I have been scratching my head for hours trying to figure out why this
I've been scratching my head over this for about an hour and a half

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.