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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:45:00+00:00 2026-05-28T03:45:00+00:00

I have three request param in my method and only if Http POST request

  • 0

I have three request param in my method and only if Http POST request body has all three parameters availableCostTypesReturn,selectedCostTypesReturn and costTypeProgramId then only this method is getting called.

Successful POST request Body

 availableCostTypesReturn=1&availableCostTypesReturn=2&availableCostTypesReturn=3&
 availableCostTypesReturn=4&selectedCostTypesReturn=5&costTypeProgramId=53

Now if my POST request body changes to

availableCostTypesReturn=1&availableCostTypesReturn=2&availableCostTypesReturn=3&
availableCostTypesReturn=4&availableCostTypesReturn=5&costTypeProgramId=53

then this method is not getting invoked.

@RequestMapping(value = "/costTypes", method = RequestMethod.POST)
public String updateCostType(
            Model model, 
            @RequestParam(value="availableCostTypesReturn")
            String[] availableCostTypesReturn,
            @RequestParam(value="selectedCostTypesReturn") 
            String[] selectedCostTypesReturn,
            @RequestParam(value="costTypeProgramId")
            int costTypeProgramId
        ) 

There are scenarios when only one of the availableCostTypesReturn, selectedCostTypesReturn parameter will be present.

Modified my method signature to this
So how can i use the same method for this.

I am using Spring MVC 3.0.x

Modified my annotation signature as per answer from Tomasz Nurkiewicz

@RequestParam(value="availableCostTypesReturn", defaultValue= "", required = false)
  • 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-28T03:45:00+00:00Added an answer on May 28, 2026 at 3:45 am

    Try with required attribute of @RequestParam set to false:

    @RequestMapping(value = "/costTypes", method = RequestMethod.POST)
    public String updateCostType(
                Model model, 
                @RequestParam(value="availableCostTypesReturn", required = false)
                String[] availableCostTypesReturn,
                @RequestParam(value="selectedCostTypesReturn", required = false) 
                String[] selectedCostTypesReturn,
                @RequestParam(value="costTypeProgramId", required = false)
                int costTypeProgramId
            ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three (C++) classes: Player, Hand, and Card. Player has a member, hand,
Let say I have a post from like this: <form action=myApp/form_action.asp method=post> First name:
I've added some parameters in my web.xml config file, as follow: <context-param> <param-name>service1</param-name> <param-value>http://www.example.com/example2.html</param-value>
Code: # it's an ajax request, so parameters are passed via GET method def
I have an MVC controller that has this Action Method: [HttpPost] public ActionResult SubmitAction()
I have a cost optimization request that I don't know how if there is
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
I have three models: class ReleaseItem < ActiveRecord::Base has_many :pack_release_items has_one :pack, :through =>
I have three unordered lists that have been created as Scriptaculous Sortables so that

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.