LibraryToggle FramesPrintFeedback

Example 3.10 shows two examples of using the @DefaultValue to specify a default value for a field whose value is injected.


The getMonster() method in Example 3.10 is invoked when a GET request is sent to baseURI/monster. The method expects two query parameters, id and type, appended to the URI. So a GET request using the URI baseURI/monster?id=1&type=fomóiri would return the Fomóiri with the id of one.

Because the @DefaultValue annotation is placed on both parameters, the getMonster() method can function if the query parameters are omitted. A GET request sent to baseURI/monster is equivalent to a GET request using the URI baseURI/monster?id=42&type=bogeyman.

Comments powered by Disqus