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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:14:35+00:00 2026-05-22T00:14:35+00:00

Guys, Well I have done enough research still I can’t find the solution to

  • 0

Guys, Well I have done enough research still I can’t find the solution to this.

In a nutshell, I’m simply passing url encoded form data to the Controller method and trying to convert it as a domain object which has Date and integers.

@RequestMapping(value = "/savePassport", method = RequestMethod.POST)
    public @ResponseBody
    AjaxResponse savePassport(@RequestBody StaffPassport passport, HttpServletResponse response) {

    // Some operations.

}

The Staff Passport looks like this:

import java.sql.Date;

public class StaffPassport {

    private int staffId;
    private String passportNumber;
    private String placeOfIssue;
    private Date issueDate;
    private Date expiryDate;
    private String spouseName;
    private String oldPassportRef;
    private String visaInfo;
    private String description;
//gets/sets
}

When I invoke the /savePassport, I get unsupported media exception. I guess it’s related to casting.

I can’t this working right. Of course I can catch individual form data using @RequestParam and manually do the casting but that’s not the point of a framework isn’t it?

Where am I going wrong? And you are right. I’m a beginner in Spring, but I love it.

  • 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-22T00:14:36+00:00Added an answer on May 22, 2026 at 12:14 am

    Looks like you’re using the wrong annotation. @RequestBody is for taking a request that has arbitrary content in its body,such as JSON, some application defined XML, comma separated variables.. whatever. And using a marshaller that you configure in the dispatcher servlet to turn it into objects.

    If all you want to do is ask Spring to bind a plain old form post onto the backing object for you, the correct annotation to put on the method parameter is @ModelAttribute.

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

Sidebar

Related Questions

maybe you guys can help me figure this out: I have a Dictionary and
Hi guys thanks for pay attention to this. Well im trying to replace every
Guys, I've came across this problem I can't resolve myselg, I'm pretty sure I
Hi guys got a wired problem (well I find it a wired problem :P)
Well guys, I have three tables here, menu, user and access. For simplifying let's
I need you guys to finally arrange this issue well in my head. As
well I have this script and basically it's doing a loop of stuff, now
OK guys, I am done with it. I have been googling for last 2
Well guys; Here's my problem: I currently have a class extending another that will
Hey guys, I'm using Twitter's PHP API, called twitterlibphp , and it works well,

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.