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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:57:13+00:00 2026-05-23T15:57:13+00:00

In last few hours I’ve read a lot concerning this topic, and so far

  • 0

In last few hours I’ve read a lot concerning this topic, and so far nothing has worked. I’m trying to return response containing “odd” some characters. Here is example of that, quite simple :

@ResponseBody
    @RequestMapping(value="test")
    public String test(){
        String test = "čćžđš";
        System.out.println(test);
        logger.info(test);
        return test;
    }

This is my web.xml, because I found some answers where CharacterEncodingFilter helped(not in my case though). I used POST method because I read this applies to POST.

Also found this answer(related). Didn’t help as well.

When I debug it the correct value appears, but when I print it doesn’t as it can be seen below:

enter image description here

When I test it from jmeter, the response seems to be OK, Content-Type is text/html;charset=UTF-8

Here is a screenshot of that as well. http://i56.tinypic.com/14lt653.jpg

I think the right way is to return UTF-8, maybe I’m wrong.

  • 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-23T15:57:14+00:00Added an answer on May 23, 2026 at 3:57 pm

    After few days of this I just had “who’s your daddy moment”. It came from reading spring 3.0 reference, I had nothing else to try so why not go trough entire documentation.. and combination of @axtavt answer :

    Who sets response content-type in Spring MVC (@ResponseBody)

    Changed original solution :

    public class EncodingPostProcessor implements BeanPostProcessor {
        public Object postProcessBeforeInitialization(Object bean, String name)
                throws BeansException {
            if (bean instanceof AnnotationMethodHandlerAdapter) {
                HttpMessageConverter<?>[] convs = ((AnnotationMethodHandlerAdapter) bean).getMessageConverters();
                for (HttpMessageConverter<?> conv: convs) {
                    if (conv instanceof StringHttpMessageConverter) {
                        ((StringHttpMessageConverter) conv).setSupportedMediaTypes(
                            Arrays.asList(new MediaType("text", "html", 
                                Charset.forName("UTF-8"))));
                    }
                }
            }
            return bean;
        }
    

    To :

    public class EncodingPostProcessor implements BeanPostProcessor {
        public Object postProcessBeforeInitialization(Object bean, String name)
                throws BeansException {
            if (bean instanceof AnnotationMethodHandlerAdapter) {
                HttpMessageConverter<?>[] convs = ((AnnotationMethodHandlerAdapter) bean).getMessageConverters();
                for (HttpMessageConverter<?> conv: convs) {
                    if (conv instanceof StringHttpMessageConverter) {
                        ((StringHttpMessageConverter) conv).setSupportedMediaTypes(
                            Arrays.asList(new MediaType("text", "plain", 
                                Charset.forName("UTF-8"))));
                    }
                }
            }
            return bean;
        }
    

    Darn spring!!! but still I’ll continue to use it.

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

Sidebar

Related Questions

For the last few hours I've been trying to set up this http://code.google.com/apis/books/docs/dynamic-links.html on
I have been struggling for the last few hours trying to get this search
I am having this array. Last few hours I have been trying to loop
This has been plaguing me for the last few hours, I'm recieving the following
I've spent the last few hours trying to find the solution to this question
This has been bugging me for the last few hours now. I am using
I have been trying to remove this Firebug Console Error from last few hours.
I've been spending the last few hours trying to find the memory leak in
I've been trying over the last few hours to implement a jQuery easing effect
I've been pulling my hair out for the last few hours with this problem.

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.