T
- Your resource POJO to manage, maybe an entity or DTO classID
- Primary resource identifier at webservice level, usually Long or Stringpublic interface RestController<T,ID extends Serializable>
Modifier and Type | Method and Description |
---|---|
T |
create(T resource)
Create a new resource
REST webservice published : POST / |
void |
delete()
Delete all resources
REST webservice published : DELETE / Return No Content http status code if the request has been correctly processed |
void |
delete(ID id)
Delete a resource by its identifier
REST webservice published : DELETE /{id} Return No Content http status code if the request has been correctly processed |
Iterable<T> |
findAll()
Find all resources, and return the full collection (plain list not paginated)
REST webservice published : GET /? |
Iterable<T> |
findAllXml()
XML findAll is currently unimplemented, see https://github.com/FasterXML/jackson-dataformat-xml/issues/38 for more details
|
T |
findById(ID id)
Find a resource by its identifier
REST webservice published : GET /{id} |
org.springframework.data.domain.Page<T> |
findPaginated(Integer page,
Integer size)
Find all resources, and return a paginated collection
REST webservice published : GET /search? |
T |
update(ID id,
T resource)
Update an existing resource
REST webservice published : PUT /{id} |
@RequestMapping(method=POST) @ResponseStatus(value=CREATED) @ResponseBody T create(@RequestBody T resource)
resource
- The resource to create@RequestMapping(value="{id}", method=PUT) @ResponseBody T update(@PathVariable ID id, @RequestBody T resource)
id
- The identifier of the resource to update, usually a Long or String identifier. It is explicitely provided in order to handle cases where the identifier could be changed.resource
- The resource to updateNotFoundException,
- BadRequestException@RequestMapping(method=GET, params="page=no", produces="application/xml") @ResponseBody Iterable<T> findAllXml()
@RequestMapping(method=GET, params="page=no", produces="application/json") @ResponseBody Iterable<T> findAll()
@RequestMapping(method=GET) @ResponseBody org.springframework.data.domain.Page<T> findPaginated(@RequestParam(value="page",required=false,defaultValue="1") Integer page, @RequestParam(value="size",required=false,defaultValue="10") Integer size)
page
- Page number starting from 0. default to 0size
- Number of resources by pages. default to 10@RequestMapping(value="{id}", method=GET) @ResponseBody T findById(@PathVariable ID id)
id
- The identifier of the resouce to findNotFoundException
@RequestMapping(method=DELETE) @ResponseStatus(value=NO_CONTENT) void delete()
@RequestMapping(value="{id}", method=DELETE) @ResponseStatus(value=NO_CONTENT) void delete(@PathVariable ID id)
id
- The identifier of the resource to deleteNotFoundException
Copyright © 2009-2012. All Rights Reserved.