Java 类org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer 实例源码

项目:cwlviewer    文件:WebConfig.java   
/**
 * Allows the use of the format query parameter to be used
 * instead of the Accept HTTP header
 */
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.favorParameter(true)
            // Browser
            .mediaType("html", MediaType.TEXT_HTML)
            // API
        .mediaType("json", MediaType.APPLICATION_JSON)
            // RDF
        .mediaType("turtle", parseMediaType("text/turtle"))
        .mediaType("jsonld", parseMediaType("application/ld+json"))
        .mediaType("rdfxml", parseMediaType("application/rdf+xml"))
            // Images
        .mediaType("svg", parseMediaType("image/svg+xml"))
        .mediaType("png", MediaType.IMAGE_PNG)
            .mediaType("dot", parseMediaType("text/vnd+graphviz"))
            // Archives
            .mediaType("zip", parseMediaType("application/zip"))
        .mediaType("ro", parseMediaType("application/vnd.wf4ever.robundle+zip"))
            // raw redirects
        .mediaType("yaml", parseMediaType("text/x-yaml"))
        .mediaType("raw", MediaType.APPLICATION_OCTET_STREAM);
}
项目:WQP-WQX-Services    文件:SpringConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer
        .favorPathExtension(false)
        .favorParameter(true)
        .parameterName("mimeType")
        .mediaType(csv.getExtension(), csv.mediaType)
        .mediaType(tsv.getExtension(), tsv.mediaType)
        .mediaType(xml.getExtension(), xml.mediaType)
        .mediaType(json.getExtension(), json.mediaType)
        .mediaType(xlsx.getExtension(), xlsx.mediaType)
        .mediaType(kml.getExtension(), kml.mediaType)
        .mediaType(kmz.getExtension(), kmz.mediaType)
        .mediaType(geojson.getExtension(), geojson.mediaType)
        .mediaType(text.getExtension(), text.mediaType)
    ;
}
项目:omero-ms-queue    文件:WebWiring.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer cfg) {
    cfg.favorParameter(false)      // disable 'resource?format=xxx'
       .favorPathExtension(false)  // disable 'resource.xxx'
       .ignoreAcceptHeader(false)  // use Accept header
       .defaultContentType(MediaType.TEXT_PLAIN);  // (*)
}
项目:Sound.je    文件:SpringConfig.java   
@Override
public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) {
    configurer.favorPathExtension(false).
            favorParameter(true).
            parameterName("mediaType").
            ignoreAcceptHeader(true).
            useJaf(false).
            defaultContentType(MediaType.APPLICATION_JSON).
            mediaType("xml", MediaType.APPLICATION_XML).
            mediaType("json", MediaType.APPLICATION_JSON);
}
项目:sc-generator    文件:WebMvcConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.mediaType("adoc", MediaType.parseMediaType("text/asciidoc;charset=utf-8"))
            .mediaType("md", MediaType.parseMediaType("text/markdown;charset=utf-8"))
            .mediaType("html", MediaType.parseMediaType("text/html;charset=utf-8"))
            .mediaType("properties", MediaType.parseMediaType("text/properties;charset=utf-8"))
            .mediaType("yml", MediaType.parseMediaType("text/yaml;charset=utf-8"))
            .mediaType("sql", MediaType.parseMediaType(MediaType.TEXT_PLAIN_VALUE + ";charset=utf-8"))
            .mediaType("jdl", MediaType.parseMediaType(MediaType.TEXT_PLAIN_VALUE + ";charset=utf-8"))
            .mediaType("doc", MediaType.parseMediaType("application/msword"));
    super.configureContentNegotiation(configurer);
}
项目:stateless-shiro    文件:WebConfig.java   
/**
 * Setup a simple strategy: use all the defaults and return JSON by default when not sure.
 */
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8).
            mediaType("xml", MediaType.APPLICATION_JSON_UTF8).
            mediaType("json", MediaType.APPLICATION_JSON);
}
项目:OntoBench    文件:WebMvcConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
  configurer.ignoreAcceptHeader(true)
      .favorParameter(true)
      .ignoreUnknownPathExtensions(false)
      .defaultContentType(OntologySyntax.RDF_XML.getMediaType())
      .mediaType("owx", OntologySyntax.OWL_XML.getMediaType())
      .mediaType("owl", OntologySyntax.RDF_XML.getMediaType())
      .mediaType("rdf", OntologySyntax.RDF_XML.getMediaType())
      .mediaType("xml", OntologySyntax.RDF_XML.getMediaType())
      .mediaType("ofn", OntologySyntax.FUNCTIONAL.getMediaType())
      .mediaType("omn", OntologySyntax.MANCHESTER.getMediaType())
      .mediaType("ttl", OntologySyntax.TURTLE.getMediaType());
}
项目:judge    文件:JudgeWebMvcConfiguration.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.TEXT_HTML);
    for (Type value : Type.values()) {
        configurer.mediaType(value.getExtension(), value.getMediaType());
    }
}
项目:multi-language-connector    文件:Application.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.favorPathExtension(false)
              .favorParameter(true)
              .parameterName("format")
              .ignoreAcceptHeader(true)
              .useJaf(false)
              .defaultContentType(MediaType.APPLICATION_JSON)
              .mediaType("json", MediaType.APPLICATION_JSON);
}
项目:spring-boot    文件:WebMVCConfig.java   
/**
 * Spring 3.2 及以上版本自动开启检测URL后缀,设置Response content-type功能, 如果不手动关闭这个功能,当url后缀与accept头不一致时,
 * Response的content-type将会和request的accept不一致,导致报 406 错误
 * 例如返回类型为 JSON 的 @ResponseBody API, 必须将请求URL后缀改为.json,以便和 accept头(application/json)相匹配,否则返回 406 错误。
 */
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {

    configurer.favorPathExtension(false). //关闭URL后缀检测的方法如下
            favorParameter(true).
            mediaType("json", MediaType.APPLICATION_JSON).
            defaultContentType(MediaType.APPLICATION_JSON);//如果没有对应的后缀名,返回信息默认以 json 格式返回

}
项目:spring-boot    文件:WebMVCConfig.java   
/**
 * Spring 3.2 及以上版本自动开启检测URL后缀,设置Response content-type功能, 如果不手动关闭这个功能,当url后缀与accept头不一致时,
 * Response的content-type将会和request的accept不一致,导致报 406 错误
 * 例如返回类型为 JSON 的 @ResponseBody API, 必须将请求URL后缀改为.json,以便和 accept头(application/json)相匹配,否则返回 406 错误。
 */
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {

    configurer.favorPathExtension(false). //关闭URL后缀检测的方法如下
            favorParameter(true).
            parameterName("mediaType").
            ignoreAcceptHeader(true).
            useJaf(false).
            mediaType("xml", MediaType.APPLICATION_XML).
            mediaType("json", MediaType.APPLICATION_JSON).
            defaultContentType(MediaType.APPLICATION_JSON);//如果没有对应的后缀名,返回信息默认以 json 格式返回

}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebMvcAutoConfiguration.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    Map<String, MediaType> mediaTypes = this.mvcProperties.getMediaTypes();
    for (Entry<String, MediaType> mediaType : mediaTypes.entrySet()) {
        configurer.mediaType(mediaType.getKey(), mediaType.getValue());
    }
}
项目:petclinic    文件:WebConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
  configurer
      .defaultContentType(MediaType.TEXT_HTML)
      .mediaType("html", MediaType.TEXT_HTML)
      .mediaType("xml", MediaType.APPLICATION_XML)
      .mediaType("json", MediaType.APPLICATION_JSON)
      .favorPathExtension(true)
      .favorParameter(true)
      .parameterName("mediaType")
      .ignoreAcceptHeader(false);
}
项目:ifsc-rest-api    文件:WebConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.favorPathExtension(false).
            favorParameter(true).
            parameterName("mediaType").
            ignoreAcceptHeader(true).
            useJaf(false).
            defaultContentType(MediaType.APPLICATION_JSON).
            mediaType("xml", MediaType.APPLICATION_XML).
            mediaType("json", MediaType.APPLICATION_JSON);
}
项目:FAIRDataPoint    文件:AbstractMetadataMessageConverter.java   
/**
 * Visitor method to configure content negotiation for this converter. 
 * @param configurer {@link WebMvcConfigurerAdapter#configureContentNegotiation(ContentNegotiationConfigurer)
 *        WebMvcConfigurerAdapter} configurer instance.
 */
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {           
    configurer.mediaType(format.getDefaultFileExtension(), 
            MediaType.parseMediaType(format.getDefaultMIMEType()));

    LOGGER.info("registering {} with {}", format.getDefaultFileExtension(), 
            format.getDefaultMIMEType());          
}
项目:spring-boot-concourse    文件:WebMvcAutoConfiguration.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    Map<String, MediaType> mediaTypes = this.mvcProperties.getMediaTypes();
    for (Entry<String, MediaType> mediaType : mediaTypes.entrySet()) {
        configurer.mediaType(mediaType.getKey(), mediaType.getValue());
    }
}
项目:workflow-catalog-old    文件:Application.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.favorPathExtension(false)
              .favorParameter(true)
              .parameterName("format")
              .ignoreAcceptHeader(true)
              .useJaf(false)
              .defaultContentType(MediaType.APPLICATION_JSON)
              .mediaType("json", MediaType.APPLICATION_JSON);
}
项目:onetwo    文件:BootMvcConfigurerAdapter.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    Properties mediaTypes = jfishBootConfig.getMvc().getMediaTypes();
    if (!CollectionUtils.isEmpty(mediaTypes)) {
        for (Entry<Object, Object> entry : mediaTypes.entrySet()) {
            String extension = ((String)entry.getKey()).toLowerCase(Locale.ENGLISH);
            configurer.mediaType(extension, MediaType.valueOf((String) entry.getValue()));
        }
    }
}
项目:report-cockpit-birt-web    文件:WebMvcConfig.java   
@Override
public void configureContentNegotiation(
        ContentNegotiationConfigurer configurer) {
    configurer.favorPathExtension(false);
    configurer.ignoreAcceptHeader(false);
    configurer.defaultContentType(MediaType.TEXT_PLAIN);

    configurer.mediaType("html", MediaType.TEXT_HTML);
    configurer.mediaType("xml", MediaType.APPLICATION_XML);
}
项目:catnap    文件:DelegatingCatnapWebMvcConfiguration.java   
@Override
protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON);
    configurer.favorPathExtension(true);
    configurer.ignoreAcceptHeader(false);
    configurer.mediaType("json", MediaType.APPLICATION_JSON);
    configurer.mediaType("jsonp", new MediaType("application", "x-javascript"));

    super.configureContentNegotiation(configurer);
}
项目:catnap    文件:WidgetConfiguration.java   
@Override
protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON);
    configurer.favorPathExtension(true);
    configurer.ignoreAcceptHeader(false);
    configurer.mediaType("json", MediaType.APPLICATION_JSON);
    configurer.mediaType("jsonp", new MediaType("application", "x-javascript"));

    super.configureContentNegotiation(configurer);
}
项目:ome-smuggler    文件:WebWiring.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer cfg) {
    cfg.favorParameter(false)      // disable 'resource?format=xxx'
       .favorPathExtension(false)  // disable 'resource.xxx'
       .ignoreAcceptHeader(false)  // use Accept header
       .defaultContentType(MediaType.TEXT_PLAIN);  // (*)
}
项目:cross-preferences    文件:Config.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
  configurer
          .favorPathExtension(false)
          .favorParameter(true)
          .ignoreAcceptHeader(false)
          .defaultContentType(MediaType.APPLICATION_JSON)
          .mediaType("json", new MediaType("application", "hal+json"))
          .mediaType("html", MediaType.TEXT_HTML);
}
项目:DependencyInjectionAgent    文件:MvcCoreConfig.java   
@Override
public void configureContentNegotiation(
        ContentNegotiationConfigurer configurer) {
    configurer.ignoreAcceptHeader(true);
    configurer.defaultContentType(MediaType.TEXT_HTML);
    configurer.mediaType("html", MediaType.TEXT_HTML);
    configurer.mediaType("xml", MediaType.APPLICATION_XML);
}
项目:SJPAReference    文件:WebContext.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    HashMap<String, MediaType> mediaTypes = new HashMap<>();
    mediaTypes.put("xml", MediaType.APPLICATION_XML);
    mediaTypes.put("json", MediaType.APPLICATION_JSON);

    configurer.mediaTypes(mediaTypes)
                .defaultContentType(MediaType.APPLICATION_JSON)
                .favorParameter(false)
                .favorPathExtension(true);

    super.configureContentNegotiation(configurer);
}
项目:simplebank    文件:WebConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    HashMap<String, MediaType> mediaTypes = new HashMap<>();
    mediaTypes.put("xml", MediaType.APPLICATION_XML);
    mediaTypes.put("json", MediaType.APPLICATION_JSON);
    configurer
        .mediaTypes(mediaTypes)
        .defaultContentType(MediaType.APPLICATION_JSON)
        .favorParameter(false)
        .favorPathExtension(true);
    super.configureContentNegotiation(configurer);
}
项目:FHIR    文件:WebConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer
            .defaultContentType(MediaType.APPLICATION_JSON)
            .favorPathExtension(false)
            .favorParameter(true)
            .parameterName("_format")
            .mediaType("json", MediaType.APPLICATION_JSON);
}
项目:arsnova-backend    文件:AppConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.mediaType("json", MediaType.APPLICATION_JSON_UTF8);
    configurer.mediaType("xml", MediaType.APPLICATION_XML);
    configurer.defaultContentType(API_V3_MEDIA_TYPE);
    configurer.favorParameter(true);
    configurer.favorPathExtension(false);
}
项目:mev    文件:DatasetRestConfiguration.java   
@Override
public void configureContentNegotiation (ContentNegotiationConfigurer configurer) {

  configurer.mediaType (TSV_EXTENSION, TSV_MEDIA_TYPE)
            .mediaType ("binary", APPLICATION_OCTET_STREAM)
            .mediaType ("binary64", MediaType.valueOf("application/x.dfci.cccb.mev.dataset.binary64"))
            .mediaType ("text", TEXT_PLAIN);
}
项目:mev    文件:ContentNegotiationConfiguration.java   
@Override
public void configureContentNegotiation (ContentNegotiationConfigurer configurer) {
  configurer.favorPathExtension (false)
            .favorParameter (true)
            .parameterName ("format")
            .ignoreAcceptHeader (true)
            .useJaf (false)
            .defaultContentType (TEXT_HTML)
            .mediaType ("html", TEXT_HTML)
            .mediaType ("json", APPLICATION_JSON);
}
项目:edoras-one-initializr    文件:WebConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentTypeStrategy(new CommandLineContentNegotiationStrategy());
}
项目:FeedbackCollectionAndMgmtSystem    文件:AppConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.ignoreAcceptHeader(true).defaultContentType(
            MediaType.TEXT_HTML);
}
项目:miscroServiceHello    文件:CustomMVCConfiguration.java   
@Override
public void configureContentNegotiation(
        ContentNegotiationConfigurer configurer) {
    configurer.favorPathExtension(false);
}
项目:jwala    文件:ApacheEnterpriseManagerWebConfig.java   
@Override
public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) {
    configurer.favorPathExtension(false).favorParameter(true).ignoreAcceptHeader(false);
}
项目:S3Mock    文件:S3MockApplication.java   
@Override
public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) {
  configurer.defaultContentType(MediaType.APPLICATION_FORM_URLENCODED);
  configurer.favorPathExtension(false);
  configurer.mediaType("xml", MediaType.TEXT_XML);
}
项目:apollo-custom    文件:WebMvcConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
  configurer.favorPathExtension(false);
  configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON);
}
项目:apollo    文件:WebMvcConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
  configurer.favorPathExtension(false);
  configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON);
}
项目:graviteeio-access-management    文件:WebMvcConfiguration.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
项目:fiat    文件:FiatConfig.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
  super.configureContentNegotiation(configurer);
  configurer.favorPathExtension(false).defaultContentType(MediaType.APPLICATION_JSON);
}
项目:comics-blog    文件:RestConfiguration.java   
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON);
}