Is it possible to create a GET
webservice in spring and using nested properties in the query? Like search.limitResults
in the following example:
localhost:8080/firstname=test&search.limitResults=10
You get the idea. Can this be achieved?
@RestController
public class MyServlet {
@RequestMapping(value = "/", method = RequestMethod.GET)
private String test(RestParams p) {
}
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class RestParams {
private String firstname;
private String lastname;
//is that possible to nest?
private Search search;
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Search {
private int limitResults;
//some more
}
To answer my own question: it just works this way! Nested properties can be accessed using the dot accessor, like search.limitResults
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.