11.11.2. Map File Extensions to Languages in the web.xml File

Task Summary

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 languages to file extensions, in the web.xml file.

Procedure 11.5. Task

  1. Open the web.xml file for the application in a text editor.
  2. Add the context-param resteasy.language.mappings to the file, inside the web-app tags:
    <context-param>
        <param-name>resteasy.language.mappings</param-name>
    </context-param>
    
  3. Configure the parameter values. The mappings form a comma delimited list. Each mapping is delimited by a ::

    Example 11.14. Example Mapping

    <context-param>
        <param-name>resteasy.language.mappings</param-name>
        <param-value> en : en-US, es : es, fr : fr</param-name>
    </context-param>