Results 1 to 2 of 2

Thread: RequestMapping for urls with very large numbers of GET vars

  1. #1

    Default RequestMapping for urls with very large numbers of GET vars

    say we have a simple search mapping

    Code:
    @RequestMapping(value = "/search", method = RequestMethod.GET)
    public String search(@RequestParam("q") String searchTerm) {
       //snipped
    }
    accessable via 'http://domain/search?q=mySearch'

    this is perfectly maintainable.

    however, we want to implement advanced search, where there can be large numbers of different GET vars
    eg 'http://domain/search/advanced?field1=value1&field2..N=value2..valueN'

    to me it seems like this could become quite a headache, in terms of maintainence and readability to have eg.
    Code:
    @RequestMapping(value = "/search/advanced", method = RequestMethod.GET)
    public String advancedSearch(@RequestParam("field1") String field1, ..@RequestParam("fieldN") String fieldN) {
       //snipped
    }
    is there a way to be able to rather have something like
    Code:
    @RequestMapping(value = "/search/advanced", method = RequestMethod.GET)
    public String advancedSearch(AdvancedSearchObject advancedSearchObject) {
       //snipped
    }
    that would allow us to still have transparent/distributable URLs?

    thanks in advance
    shaine

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    You already wrote your own solution... As long as the getter/setter pairs match the object they will be bound. I strongly suggest a read of the reference guide especially the part covering web and especially forms.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

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