Results 1 to 2 of 2

Thread: @RequestParam value field for POJOs holding request parameters?

  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Default @RequestParam value field for POJOs holding request parameters?

    Hi

    Please excuse a somewhat stupid question but I am having a problem with @RequestParam which I can't seem to get around.

    Im creating a service that takes 30+ request parameters. Some of these parameters are named so that I can not create fields in java to match their names. I have no control over the parameter names. With then @RequestParam annotation I can use the value field to map names to method arguments. How do I do the same for fields in a POJO?

    Example of how its done with @RequestParam

    Code:
    public void doSomething(@RequestParam(value="-stupid_name1") validParamNameOne,@RequestParam(value="stupid-name2") validParamNameTwo (...))
    This becomes quite cumbersome with 30+ parameters. So I want to do:

    Code:
    public void doSomething(ParamPojo paramPojo)
    and then in ParamPojo do

    Code:
    class ParamPojo{
    
    @NiceAnnotation(value="-stupid_name1") // <- this annotation or equivalent is what i am looking for
    private String validParamNameOne;
    
    }
    Is there a way this can be done or have I missed something regarding how spring handles binding of paramaters that can not match java fields?

  2. #2

    Default

    But you can create a java object with fields matching named parameters. you can use String[], any other collection type (List<String>) to match your group of checkboxes, radio buttons or multiple selected dropdowns, etc. refer this: http://static.springsource.org/sprin...jsp-formtaglib

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •