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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:30:55+00:00 2026-06-13T09:30:55+00:00

I am running a Spring 3.1.2 application. I have a RESTful servlet with a

  • 0

I am running a Spring 3.1.2 application. I have a RESTful servlet with a number of methods. The GET methods are working fantastic (@PathVariables matching, responses correctly marshalled to JSON or XML based on the Accept header, etc) 100% of the time.

However the POST method is simply not working. After hours of messing around with converts and every other Spring aspect I could find (all tinkering reverted), I narrowed it do to the required field in @RequestParam. This is a simplified test method I’ve been using to investigate:

@RequestMapping (value = "/bogus",
                 method = POST)
public @ResponseBody PassResponse bogus (
            @RequestParam (value = "test", required = false) String test) {
    // Just some handy garbage objects that marshal to JSON/XML
    UserResponse user = new UserResponse ();
    user.setName (test);
    AccountDetail detail = new AccountDetail (user,null);
    return new PassResponse (detail);
}

required=false: everything works (parameter is received and interpreted). Exactly as I expect it to work

required=true: (or not specified, since this is the default) I consistently get the message “MissingServletRequestParameterException: Required String parameter ‘test’ is not present“

Client side view:

required=true

Request URL:http://localhost:8080/internal-project/rest/bogus
Request Method:POST
Status Code:400 Bad Request
Request Headersview source
Accept:application/json
Connection:keep-alive
Content-Length:12
Host:localhost:8080
Request Payload
test=LALALAA
Response Headersview source
Connection:close
Content-Length:971
Content-Type:text/html;charset=utf-8
Date:Wed, 24 Oct 2012 18:41:05 GMT
Server:Apache-Coyote/1.1

required=false

Request URL:http://localhost:8080/internal-project/rest/bogus
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json
Connection:keep-alive
Content-Length:12
Host:localhost:8080
Request Payload
test=LALALAA
Response Headersview source
Content-Type:application/json;charset=UTF-8
Date:Wed, 24 Oct 2012 18:44:03 GMT
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked

It is the exact same test suite being run when toggling required and I can see the parameter is being passed. When the parameter is optional, Spring handles the it correctly.

If anyone has run across this before or has any ideas I’d love to hear them. Marking the required parameter as optional, even if it works, is terrible self documentation even if I comment it. Plus the behavior is making me a little nervous. Hopefully I just screwed something up somewhere…

  • 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-13T09:30:56+00:00Added an answer on June 13, 2026 at 9:30 am

    Your Content-Type header should be application/x-www-form-urlencoded I think.

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

Sidebar

Related Questions

I have a j2ee application running on spring framework. I am trying to apply
I have a j2ee application running on spring framework. I am implementing a transaction
I have a j2ee web application running on Spring framework. I want to implement
I have an extremely simple web application running in Tomcat using Spring 3.0.2, Hibernate
I have a jython servlet as part of a large application running in tomcat5.
I have a web application running on Spring Webflow with Spring Security. I have
I have a j2ee web application running on spring web flow using spring security.
I have a Spring application running on the Glassfish Webserver and I'm seeing some
We have a web application (JQuery and Spring) running on weblogic app server. There
I have a Spring application, which is running on Tomcat say at: http://example.com/foo/ DisplatcherServlet

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.