Announcement Announcement Module
Collapse
No announcement yet.
@RequestParam value field for POJOs holding request parameters? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @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
    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

    Comment

    Working...
    X