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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:31:15+00:00 2026-06-18T08:31:15+00:00

I have a very similiar problem solved in this thread: click To make a

  • 0

I have a very similiar problem solved in this thread: click

To make a long story short:

I’m generating form elements dynamically with jQuery and in the result it looks like this:

<div id="XYZ-1">
<input type="text" id="XYZ-1-position" name="XYZ-1-position" style="width: 20px;"/>
<input type="text" id="XYZ-1-input" name="XYZ-1-value" style="width: 400px;"/>
</div>

<div id="XYZ-2">
<input type="text" id="XYZ-2-position" name="XYZ-2-position" style="width: 20px;"/>
<input type="text" id="XYZ-2-input" name="XYZ-2-value" style="width: 400px;"/>
</div>

So for handling one form field, I’m using just this simple @ReqeustParam:

     @RequestMapping(value = "/data", method = RequestMethod.POST)
 public String myHandler(@RequestParam("XYZ-1-value")String content, Model model) {

    model.addAttribute("dataset", content); 
            return "data"

In the Thread of the beginning of my post it is solved like:

public String controllerMethod(@RequestParam(value="myParam[]") String[] myParams){
....
}

And this works for input types with the same name:

<input type="checkbox" name="myParam[]" value="myVal1" />
<input type="checkbox" name="myParam[]" value="myVal2" />

But the difference to my problem is, that my form elements do NOT have the same name – each has an individual Name.

So my question is how I can handle these individual post-parameters in a single handler in my controller.

Thanks in advance

  • 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-18T08:31:16+00:00Added an answer on June 18, 2026 at 8:31 am

    The pattern I like for this sort of thing is to have a form bean that contains a list (or map) of beans that wrap my individual values. So, I would have:

    public class FormBean {
      private List<FormItem> items;
      //...getters/setters
    }
    

    and

    public class FormItem {
      private String val1;
      private Integer val2;
      //...getters/setters
    }
    

    And controller method:

    @RequestMapping()
    public String default(@ModelAttribute("formBean") FormBean formBean) {
       // Blah blah blah
    }
    

    On the view-side, the mapping name would look like:

    <input type="text" name="formBean.items[0].val1" />
    <input type="text" name="formBean.items[0].val2" />
    

    Or you could use the JSTL tags:

    <form:form modelAttribute="formBean">
      <form:input path="items[0].val1" />
      <form:input path="items[0].val2" />
    </form:form>
    

    This way everything is nice and packaged up, and its really easy on the view-side to parse the name when adding new rows.

    EDIT

    Simple example on auto-placing models into session (I am typing this from memory…please validate on your own)

    Controller:

    @Controller
    @RequestMapping("/form")
    @SessionAttributes({"formBean"})
    public class FormController {
        @RequestMapping()
        public String defaultView(@ModelAttribute("formBean") FormBean formBean, Model uiModel) {
            // Do something...add anything to the uiModel that you want to use in your form...you should not need to add formBean as it should auto-matically get put into session now with the @SessionAttributes annotation
            // Also to note, if you set the "formBean" attribute on the Model or ModelAndView, it will replace the one in Session.  Also, you can add the SessionStatus to one of your methods and use its .setComplete() method to indicate you are done with the session...you usually do this after you know the user is done with the application so the session can get cleaned up.
        }
    
        @RequestMapping("/someOtherPath")
        public String someOtherHandler(@ModelAttribute("formBean") FormBean formBean, Model uiModel) {
            // Do something...again, formBean should be either created or out of session
        }
    
        @ModelAttribute("formBean")
        private FormBean createFormBean() {
            // This method can be named anything, as long as it returns a FormBean, has the @ModelAttribute named on it, and has no arguments.  Use this method to populate your FormBean when its created (set defaults and such).
            return new FormBean();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very specific problem in T-SQL. If I can solve this example
My current problem is very similar to this one . I have a downloadFile(URL)
I have a problem very similar than this post . In every row of
I have something very similar to this example: https://developers.google.com/maps/documentation/javascript/examples/directions-simple All I am trying to
I was looking at this post: https://stackoverflow.com/a/2262200 and I have a very similar setup
I know that this is a repeated question. I have found very similar questions
I think I have a very popular problem, but not found answer for it
I'm very new to Python and I have a problem which I thought I
I have a very long page that dynamically loads images as users scroll through.
I have a very tough problem I can't solve. I have an app which

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.