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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:19:31+00:00 2026-06-02T01:19:31+00:00

Follwing the examples from Krams . What does the below return, will the Person

  • 0

Follwing the examples from Krams. What does the below return, will the Person object be converted to JSON or XML based on the header of submitted request ?

 @RequestMapping(value = "/person", 
           method = RequestMethod.POST, 
           headers="Accept=application/xml, application/json")
 public @ResponseBody Person addPerson(@RequestBody Person person) {
     logger.debug("Provider has received request to add new person");

     // Call service to here
     return personService.add(person);
    }

So when I submit data as json I get json back, and the same for xml. Or is something else going on ?

  • 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-02T01:19:32+00:00Added an answer on June 2, 2026 at 1:19 am

    It depends on Accept http request header. If it’s json, you get json, if it’s xml you get xml.

    That’s exactly what this part of your code says.:

    ....
    headers="Accept=application/xml, application/json")
    ...
    

    You can send one mime type and receive another without problems.

    edit

    Both headers and produces/consumes parameters only say what can be produced/consumed by the requestmapping. They don’t force any particular serialization. The type of request/response is decided entirely in request headers. If the dispatcher doesn’t find mapping with produces and consumes (or headers) matching the request headers you’ll get an error.

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

Sidebar

Related Questions

Take the below image I will use for the following examples: The dimensions unchaged
Im trying to hammer togehter a WYSIWYG-edit in c# following some examples from here
I took the following code from the examples page on Asio class tcp_connection :
Ive got the following code which I hacked together from website examples. It works
I am working on my first login script. I have been following examples from
I'm following the examples from the book 'Programming Clojure', and I'm at page 17
I need to get the domain name from an URL. The following examples should
I'm new to pgf so i was trying out some examples from the pgfplot
I've managed to get a JSON output from my database for use with jQuery
I have recently started following the examples from The Little Schemer and when trying

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.