Код: Выделить всё
@RequestMapping(method = RequestMethod.POST,
consumes = {MediaType.APPLICATION_XML_VALUE},
produces = {MediaType.APPLICATION_XML_VALUE})
< /code>
Однако, поскольку большинство конечных точек моего приложения будут только json < /code>, я хотел избежать необходимости писать < /p>
consumes = {MediaType.APPLICATION_JSON_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE}
< /code>
во всех из них. Есть ли способ сделать метод, аннотированный с помощью @Requestmapping Код: Выделить всё
@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>
и конечная точка с < /p>
@RequestMapping(method = RequestMethod.GET)
< /code>
Затем вызов конечной точки < /p>
GET https://localhost:8080/endpoint.xml
Подробнее здесь: https://stackoverflow.com/questions/528 ... ot-service