13.11. Configure File Extensions
13.11.1. Map File Extensions to Media Types in the web.xml File
Some clients, like browsers, cannot use the Accept and Accept-Language headers to negotiate the representation's media type or language. RESTEasy can map file name suffixes to media types and languages to deal with this issue. Follow these steps to map media types to file extensions, in the web.xml
file.
Procedure 13.4. Map Media Types to File Extensions
- Open the
web.xml
file for the application in a text editor. - Add the context-param
resteasy.media.type.mappings
to the file, inside theweb-app
tags:<context-param> <param-name>resteasy.media.type.mappings</param-name> </context-param>
- Configure the parameter values. The mappings form a comma delimited list. Each mapping is delimited by a
:
:Example 13.13. Example Mapping
<context-param> <param-name>resteasy.media.type.mappings</param-name> <param-value>html : text/html, json : application/json, xml : application/xml</param-value> </context-param>