Este contenido no está disponible en el idioma seleccionado.

15.10. Configure File Extensions


15.10.1. Map File Extensions to Media Types in the web.xml File

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

Procedure 15.4. Map Media Types to File Extensions

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

    Example 15.16. 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>
    

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

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 15.5. Map File Extensions to Languages in the web.xml File

  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 15.17. Example Mapping

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

15.10.3. RESTEasy Supported Media Types

Table 15.4. Media Types
Media Type Java Type
application/*+xml, text/*+xml, application/*+json, application/*+fastinfoset, application/atom+* JaxB annotated classes
application/*+xml, text/*+xml org.w3c.dom.Document
*/* java.lang.String
*/* java.io.InputStream
text/plain primitives, java.lang.String, or any type that has a String constructor, or static valueOf(String) method for input, toString() for output
*/* javax.activation.DataSource
*/* byte[]
*/* java.io.File
application/x-www-form-urlencoded javax.ws.rs.core.MultivaluedMap
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.