Resources are registered with a REST resource registry that has a context root defined in the web.xml file. This context root takes the following format:

/context/version

The context is the root context of the Web application with the version number, which indicates the version number of the resource and provides tracking for backward compatibility. For example, a URI may be /public/v1. The full URI would be http://localhost:8080/public/v1.

Code endpoint responses to work with URIs that are relative to the context root. For example, the URI would be /cart instead of /public/v1/cart.

Locating Collection URIs

When creating a URI to locate a collection resource, use the /resourceName convention. As described in the Before You Begin section, resource names should be nouns, should follow a generic naming standard, and should start with a lower case letter. For example, the order resource URI might be /orders.

Best Practices When Creating URIs

When creating a singular resource URI, it is best to follow the collectionResourceUri/resourceId convention, for example, /orders/01/items/c1, where the collectionResourceUri is the corresponding collection resource URI and that the resourceId identifies a resource within its collection.

An endpoint or resource class contains methods that provide operations that are specific for that resource. It is best to define the URI of the endpoint method in accordance with your resource naming standards. When you are writing endpoint/resource classes it is helpful to keep the following in mind:


Copyright © 1997, 2019 Oracle and/or its affiliates. All rights reserved. Legal Notices