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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:56:54+00:00 2026-05-25T17:56:54+00:00

I have Spring REST application that can marshall an object to JSON when a

  • 0

I have Spring REST application that can marshall an object to JSON when a GET request occurs. However what should I do for POST methods. I send a JSON object but it can’t unmarshall it into a Java object. Here is a method of my controller:

@RequestMapping(value = "/user", method = RequestMethod.POST)
public void createUser(HttpServletResponse response, @RequestBody User user) { 
   ...
    response.setStatus(HttpServletResponse.SC_OK);
}

I send my JSON like that:

        var userName = $('#userName').val();
        var password = $('#password').val();
        var mail = $('#mail').val();
        var admin = $("#admin").is(':checked');
        var user = {userName: userName, password: password, mail: mail, admin:admin};
        $.ajax({
            async : false,
            type: 'POST',
            contentType: 'application/json',
            url: '/sfd/user',
            data: user,
            dataType: 'json',
            success: function(data) {
               ...
            },
            error: function(data) {
                ...
            }
        });

PS:
Here: http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/ it says:

If there are validation errors, a HTTP 400 is returned with the
error messages, otherwise a HTTP 200 is returned.

I have 400 Bad Request Error. Maybe the problem is related to that?

PS2: Should I send User object after I set all its elements? I mean User object has some other attributes, i.e. address but I don’t set and send it from client.

PS3: When I debug AbstractHandlerExceptionResolver’s resolveException method I see that error. It says ‘u’ is undefined character(I tested it that ‘u’ is the first key of JSON => userName’s first character).

  • 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-25T17:56:55+00:00Added an answer on May 25, 2026 at 5:56 pm

    You should have the following setting in your XML:

    <context:annotation-config/> 
    

    and then to make sure that jackson jar is in your classpath:

    in my projects I prefer to set it as Spring Bean:

    it will deserialize your json data to object.

    You can read it more about it here:

    http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/

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

Sidebar

Related Questions

I have a spring application that uses an embedded Jetty instance. Since I am
I have a Spring Web MVC application that I'd like to serve a large,
I have a ASP.NET Web Forms application that internally makes many SOAP and REST
I have a (REST) application that handles CRUD operations initiated by a 3rd party,
We have a C# .Net client application that sends some commands via REST over
I have figured out that I can use hibernate to get the sum of
I have a Spring 3.0 web application which tries to follow the REST principles
I have an application built on Spring MVC that uses Hibernate for all of
Is it possible to have Spring inject the JPA entityManager object into my DAO
I have a Spring controller that returns XHTML, what's the easiest way to setup

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.