0
저는 JAX-RS에서 Spring에 이민 온 사람입니다. 내 다음 코드와 Spring에서 application/xml의 요소 목록에 어떻게 응답합니까?
,@RequestMapping(method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE,
MediaType.APPLICATION_XML_VALUE})
public @ResponseBody ResponseEntity<List<Item>> read() {
final List<Item> body
= range(0, current().nextInt(1, 10))
.mapToObj(i -> Item.newRandomInstance())
.collect(toList());
return ResponseEntity.ok(body);
}
나는 application/xml
에 대한 application/json
하지만 406
에 대한 200
를 얻을.
이 문제를 해결하는 가장 좋은 방법은 무엇입니까?
자동 복수 배치 기능이 있습니까?
은 여기 내 종속
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
// exclude module: "spring-boot-starter-tomcat"
}
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
// compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile('org.springframework.boot:spring-boot-starter-test')
compile("org.springframework.boot:spring-boot-configuration-processor")
testCompile('com.jayway.jsonpath:json-path') // for gs-rest-service
// ----------------------------------------------------------------------------------------------- springfox-swagger
compile 'io.springfox:springfox-swagger2:2.7.0'
compile 'io.springfox:springfox-swagger-ui:2.7.0'
//compile('org.springframework.boot:spring-boot-starter-amqp') // rabbitmq
}
json 및 xml 메시지 변환기가 있습니까? Accept 헤더 (application/xml, application/json)가 다른 요청을 보내시겠습니까? –
@DmitrySenkovich 네, 컬을 사용하여 테스트하고 있습니다. –
나는'spring-boot-starter-web'도 사용하고 있습니다. 나는 기본적으로'HttpMessageConverter'를 설정하지 않는지 확인했습니다. 그래서 그것은 xml 구성을 잊어 버린 동안 json 변환기가있는 것처럼 보입니다. –