Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Pack multiple parameters in URL to single unit

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Pack multiple parameters in URL to single unit

    Hi All

    Is there a easy way to pack multiple parameters in URL to single unit and send to Spring MVC Controller? I have more than 20 parameters and it is inconvenience to type @RequestParam for each of them.

    Also how we can handle parameters if it can change in size e.g if I have some list of info which vary in size?

    Thanks


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,529
    My Mood
    Hungover
    Thanks
    144
    Thanked 647 Times in 552 Posts

    Default Re: Pack multiple parameters in URL to single unit

    Create an Object that contains your parameters. Add that Object as a parameter to your controller method. Let Spring do the rest for you.

    More info here: java - Spring MVC: Complex object as GET @RequestParam - Stack Overflow
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Pack multiple parameters in URL to single unit

    Need some clarification on this. So is that mean
    1. I have to create parameter string in client side?
    2. My URL still looks testapp.com......
    3. Is there any cleaner way to create the parameter in client side other than string concatenation?

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,529
    My Mood
    Hungover
    Thanks
    144
    Thanked 647 Times in 552 Posts

    Default Re: Pack multiple parameters in URL to single unit

    1. I'm not sure what you're asking. Did you try this?
    2. Okay. Did you try this?
    3. I'm not sure what you're asking. What have you tried?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Pack multiple parameters in URL to single unit

    I got answer after doing myself
    1. I am using jquery AJAX call so data: $form.serialize() did all for me.
    2. No URL doesn't look ugly
    3. This is a cleaner way.

Similar Threads

  1. Storing Multiple Phone Numbers into Single Array
    By HiTechRedneck3 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 10th, 2014, 05:17 AM
  2. UDP single vs multiple socket performance
    By ddeveloper89 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 8th, 2013, 10:50 AM
  3. Best way to turn a single class into multiple classes
    By JoeBrown in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 21st, 2012, 11:57 AM
  4. Can single MDB subscribe multiple topics?
    By shptlucky in forum Web Frameworks
    Replies: 0
    Last Post: April 22nd, 2011, 06:52 AM
  5. Conversion from multiple ints to single string
    By surfbumb in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 12th, 2011, 10:08 PM

Tags for this Thread