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

  • Home
  • SEARCH
  • 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 7664187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:14:29+00:00 2026-05-31T14:14:29+00:00

I have a JacksonMessageConverter in my Spring application for returning JSON response. But before

  • 0

I have a JacksonMessageConverter in my Spring application for returning JSON response.
But before the JSON is returned, I would like to taint the JSON as given in Ajax Security – Preventing JSON hijacking. Is it possible to do so when using a message converter?

Update

Am looking for a solution similar to this spring prefixjson with responsebody but I already have the configuration set up correctly. PFB

<bean id="jacksonMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
    <property name="prefixJson" value="true" />
    <property name="supportedMediaTypes" value = "text/plain;charset=UTF-8" />
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list>
            <ref bean="jacksonMessageConverter"/>
        </list>
    </property>
</bean>

But still the returned JSON is not prefixed with “&&{}”.

NOTE : I would like to use a different prefix for the JSON as explained in Ajax Security – Preventing JSON hijacking
but even the default support provided in Jackson does not seem to work. Any ideas?

  • 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-31T14:14:30+00:00Added an answer on May 31, 2026 at 2:14 pm

    Try to debug MappingJacksonHttpMessageConverter to see, if prefixJson equals true.
    If not, then your bean not injected propely.
    If yes, look in the writeInternal() method of MappingJacksonHttpMessageConverter class. IT clearly do what you need:

    try {
            if (this.prefixJson) {
                jsonGenerator.writeRaw("{} && ");
            }
            this.objectMapper.writeValue(jsonGenerator, o);
        }
    

    If you want to add custom prefix, you need to override writeInternal() and do it there.

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

Sidebar

Related Questions

Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Have a n-tire web application and search often times out after 30 secs. How
Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in
Have posting working wonderfully, and reading the response happily EXCEPT when one of the
have some headers like: HTTP/1.1 100 Continue HTTP/1.1 302 Found HTTP/1.1 200 OK HTTP/1.1
Have a problem that seems easy on paper but i'm having a big problem
Have advancements in CPU design like dynamic instruction scheduling narrowed the performance gap between
Have just started converting an existing job tracking system into an ASP.NET MVC application.
Have started playing with Xcode 4.2, and created a single page application using storyboard

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.