Book Image

RESTful Java Web Services, Second Edition

Book Image

RESTful Java Web Services, Second Edition

Overview of this book

Table of Contents (17 chapters)
RESTful Java Web Services Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding data binding rules in JAX-RS


While injecting variable values from the URI path and the query parameter into the resource class or mapping the request-response entity body with the Java types, the JAX-RS runtime follows certain rules for the Java types present in the resource class. We will discuss this topic in this section.

Mapping the path variable with Java types

At runtime, the framework automatically detects and copies the parameter values present in the inbound request into the appropriate Java types on the basis of the following rules:

JAX-RS allows you to use @QueryParam and @PathParam on the following Java types:

  • All primitive types such as short, int, float, double, and Boolean, except char.

  • All the wrapper classes of primitive types, such as short, integer, BigDecimal, and Boolean, except char.

  • All classes with a constructor that accepts a single string type argument. In this case, you can define your own class with a single string type constructor and use it as a method...