Code: Select all
@RequestMapping(method = RequestMethod.POST,
consumes = {MediaType.APPLICATION_XML_VALUE},
produces = {MediaType.APPLICATION_XML_VALUE})
< /code>
Da die meisten Endpunkte meiner Anwendung nur JSON < /code> sind, wollte ich vermeiden, < /p>
schreiben zu müssenconsumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE}
< /code>
In allen. Gibt es eine Möglichkeit, eine mit @RequestMapping Code: Select all
@Configuration
@EnableWebMvc
class ContentNegotiationConfiguration extends WebMvcConfigurerAdapter {
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorParameter(false)
.favorPathExtension(true)
.ignoreAcceptHeader(true)
.ignoreUnknownPathExtensions(false)
.useJaf(false)
.defaultContentType(MediaType.APPLICATION_JSON);
}
}
< /code>
und Endpunkt mit < /p>
@RequestMapping(method = RequestMethod.GET)
< /code>
Rufe dann den Endpunkt < /p>
aufGET https://localhost:8080/endpoint.xml
Mobile version