Java Reference
In-Depth Information
The
resteasy.media.type.mappings
content parameter is added to define a mapping
between various file suffixes and the media types they map to. A comma separates each
entry. The suffix string makes up the first half of the entry and the colon character delimits
the suffix from the media type it maps to. Here, we've defined mappings between
.html
and
text/html
,
.txt
and
text/plain
, and
.xml
and
application/xml
.
Build and Run the Example Program
Perform the following steps:
1. Open a command prompt or shell terminal and change to the
ex09_2
directory of the
workbook example code.
2. Make sure your PATH is set up to include both the JDK and Maven, as described in
3. Perform the build and run the example by typing
maven jetty:run
.
The
jetty:run
target will run the servlet container so that you can make browser invoca-
tions on it. Now, open up your browser and visit
http://localhost:8080/customers/1
.
Doing so will show you which default media type your browser requests. Each browser may
be different. For me, Firefox 3.x prefers HTML, and Safari prefers XML.
Next, browse each of the following URLs:
http://localhost:8080/customers/1.html
,
ht-
tp://localhost:8080/customers/1.txt
, and
http://localhost:8080/customers/1.xml
. You should
see a different representation for each.