List of usage examples for org.springframework.web.servlet.config.annotation ContentNegotiationConfigurer favorPathExtension
public ContentNegotiationConfigurer favorPathExtension(boolean favorPathExtension)
From source file:spring.travel.site.AppConfigurer.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false).useJaf(false).defaultContentType(MediaType.TEXT_HTML).mediaType("json", MediaType.APPLICATION_JSON); }
From source file:com.vgorcinschi.concordiafootballmanager.rest.RestServletContextConfiguration.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false).favorParameter(false).ignoreAcceptHeader(false) .defaultContentType(MediaType.APPLICATION_JSON); }
From source file:org.ow2.proactive.procci.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); }
From source file:com.kajj.tools.logviewer.config.LogViewerConfig.java
/** * Disables the check to favor the path extension so the content type isn't decided based on the * extension (otherwise .log can't be returned as plain/text). * * @param configurer The content negotiation configuration. *//*from w w w . j a v a2s .c om*/ @Override public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false); }
From source file:com.aestheticsw.jobkeywords.web.config.WebConfiguration.java
/** * The configureContentNegotiation() method configures the request-URL extensions to pull either * XML or JSON from the rest controllers. * /*from w w w . ja v a 2s .co m*/ * This allows the client to specify either *.json or *.xml which will pull the correct type - * but only as long as the controller method does not constrain the return type with the * "produces" annotation attribute. * * - Enables path extension. Note that favor does not mean use one approach in preference to * another, it just enables or disables it. The order of checking is always path extension, * parameter, Accept header. * * - Enable the use of the URL parameter but instead of using the default parameter, format, we * will use mediaType instead. * * - Ignore the Accept header completely. This is often the best approach if most of your * clients are actually web-browsers (typically making REST calls via AJAX). * * - Don't use the JAF, instead specify the media type mappings manually - we wish to support * JSON and XML - and HTML (via Thymeleaf templates). */ @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(true).favorParameter(true).parameterName("mediaType").ignoreAcceptHeader(true) .defaultContentType(MediaType.APPLICATION_JSON).useJaf(false) .mediaType("xml", MediaType.APPLICATION_XML).mediaType("json", MediaType.APPLICATION_JSON); }
From source file:com.work.petclinic.config.WebMvcConfig.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(true).favorParameter(true); }
From source file:gt.dakaik.config.WebContext.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false).favorParameter(false).ignoreAcceptHeader(false).useJaf(false) .defaultContentType(MediaType.APPLICATION_JSON).mediaType("xml", MediaType.APPLICATION_XML) .mediaType("json", MediaType.APPLICATION_JSON); }
From source file:net.ljcomputing.sr.config.StatusReporterMvcConfiguration.java
/** * @see org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter#configureContentNegotiation(org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer) *//*from w w w . j a v a 2 s .c o m*/ @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(true).useJaf(false).ignoreAcceptHeader(false) .defaultContentType(MediaType.APPLICATION_JSON); }
From source file:xyz.lxie.springboot.api.SwaggerAutoConfiguration.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(true).ignoreUnknownPathExtensions(true).favorParameter(false) .ignoreAcceptHeader(true).useJaf(false).defaultContentType(MediaType.APPLICATION_JSON); // this is the key to make spring mvc respond with json result only! configurer.defaultContentTypeStrategy(nativeWebRequest -> { List<MediaType> medias = new ArrayList<>(); medias.add(MediaType.APPLICATION_JSON); return medias; });//www .j a va 2s . c om }
From source file:com.expedia.seiso.SeisoWebConfig.java
@Override protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) { // @formatter:off configurer.favorPathExtension(false).favorParameter(false).ignoreAcceptHeader(false).useJaf(false) // https://github.com/ExpediaDotCom/seiso/issues/48 // Use application/json as the default to avoid a breaking change to the v1 API. // .defaultContentType(MediaTypes.APPLICATION_HAL_JSON); .defaultContentType(MediaType.APPLICATION_JSON); // @formatter:on }