Announcement Announcement Module
Collapse
No announcement yet.
UriTemplate and optional query parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Check UriComponentsBuilder in Spring 3.1. You can add query params in a loop.

    Comment

    Working...
    X