Results 1 to 2 of 2

Thread: UriTemplate and optional query parameters

  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Default UriTemplate and optional query parameters

    Hi,

    I am looking for a way to generate url with optional query parameters.
    I start with an object

    public class MyObject{

    private String name;
    private Integer age;

    //.. setters getters

    }

    Depending on attribute values, I need to produce different urls.
    For example:
    www.my.url/test/?name=myname&age=myage //in this case both name and age have values
    www.my.url/test/?age=myage //name is null
    www.my.url/test/?name=myname //age is null

    I thought that I can use the UriTemplate, but could not figure out the way.

    Any help is appreciated.
    Thanks,
    Julia

  2. #2
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    Check UriComponentsBuilder in Spring 3.1. You can add query params in a loop.

Tags for this Thread

Posting Permissions

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