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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:02:47+00:00 2026-05-26T17:02:47+00:00

I am using Spring MVC’s charset filter. This is the URL that I use

  • 0

I am using Spring MVC’s charset filter. This is the URL that I use to invoke my servlet from my applet

http://192.168.0.67/MyServlet?p1=団

As you can see, the parameter has a unicode character 団. So I use

URLEncoder.encode("団", "UTF-8"); 

and now my URL becomes

http://192.168.0.67/MyServlet?p1=%E5%9B%A3

However, from the servlet, calling

request.getParameter("p1"); 

already return some gibberish that cannot be decoded with URLDecoder. BTW, invoking

URLDecoder.decode("%E5%9B%A3", "UTF-8"); 

does give me the original unicode character. It’s just that the servlet has garbled the parameter before it can even be decoded. Does anyone know why? request.getParameter() doesn’t decode parameter with UTF-8?

  • 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-26T17:02:48+00:00Added an answer on May 26, 2026 at 5:02 pm

    The Spring MVC’s charset filter will only set the request body encoding, not the request URI encoding. You need to set the charset for the URI encoding in the servletcontainer configuration. Lot of servletcontainers default to ISO-8859-1 to decode the URI. It’s unclear what servletcontainer you’re using, so here’s just an example for Tomcat: edit the <Connector> entry of /conf/server.xml to add URIEncoding="UTF-8":

    <Connector ... URIEncoding="UTF-8">
    

    If you can’t edit the server’s configuration for some reason (e.g. 3rd party hosting and such), then you should consider to use POST instead of GET:

    String query = "p1=" + URLEncoder.encode("団", "UTF-8");
    URLConnection connection = new URL(getCodeBase(), "MyServlet").openConnection();
    connection.setDoOutput(true); // This sets request method to POST.
    connection.getOutputStream().write(query.getBytes("UTF-8"));
    // ...
    

    This way you can in doPost() use ServletRequest#setCharacterEncoding() to tell the Servlet API what charset to use to parse the request body (or just rely on the Spring MVC’s charset filter from doing this job):

    request.setCharacterEncoding("UTF-8");
    String p1 = request.getParameter("p1"); // You don't need to decode yourself!
    // ...
    

    See also:

    • Unicode – How to get the characters right?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Spring MVC 2.5. I want to redirect to a url from
I'm using Spring's form tag library in a Spring MVC application that I am
I'm currently migrating a project that is using Spring MVC without annotations to Spring
This is an example of using ThrowawayController in Spring MVC: public class DisplayCourseController implements
I'm using Spring 2.5 MVC and want to add another third-party Servlet. The Problem
I'm trying to make this 2-player web game application using Spring MVC. I have
In the context of an MVC application (using Spring MVC in this case), given
I am using Spring MVC and want to develop a website that uses REST
I'm using Spring MVC 3.0 and Tomcat. I have a bean that has a
Hi I am using Spring MVC 3 with annotations. How do I use multiple

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.