JAX-RS (REST)No Comments

In JAX-RS, you can use @Path to bind URI pattern to a Java method. See following examples to show you how it works.

  • Normal URI Matching

See normal URI matching with @Path annotation.

URI pattern : “/users

URI pattern : “/users/vip

  • URI Matching and Parameter

The value within an open brace “{” and close brace “}”, is represents a parameter, and can be access with @PathParam.

URI Pattern : “/users/javasail

URI Pattern : “/users/abcdefg

  • URI Matching and Regular Expression

@Path support complex URI matching with regular expression, via following expression :

URI Pattern : “/users/999

URI Pattern : “/users/123456

 

URI Pattern : “/users/username/aaa” , failed, don’t match “[a-zA-Z][a-zA-Z_0-9]”, first character need “[a-zA-Z]”, second character need “[a-zA-Z_0-9]”.

URI Pattern : “/users/username/a9

URI Pattern : “users/books/999


Be the first to post a comment.

Add a comment


Warning: stream_socket_client(): unable to connect to http://browscap.org/version (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in /home/javasail/public_html/wp-content/plugins/wp-statistics/vendor/browscap/browscap-php/src/phpbrowscap/Browscap.php on line 1366

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/javasail/public_html/wp-content/plugins/wp-statistics/vendor/browscap/browscap-php/src/phpbrowscap/Browscap.php on line 769