membersound:
私が作成し、単純なWebサービスを作成したいtext/csv
コンテンツを。しかし、私はそれを要求することはできません。
@RestController
public class MyServlet {
@PostMapping(produces = {"text/csv", "application/json"})
public Object post() {
//...
}
}
spring.mvc.contentnegotiation.media-types.csv=text/csv
私はポストの要求を送信するとContent-Type: text/csv
、HTTPヘッダとして、私は次のエラーを取得しています:
415: Content type 'text/csv' not supported
これは私の設定です:
@Configuration
public class ContentNegotiationConfiguration implements WebMvcConfigurer {
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer
.favorParameter(true) //favor &format=csv
.defaultContentType(MediaType.APPLICATION_JSON)
.parameterName(format);
//.mediaType("csv", new MediaType("text", "csv")) //also tried without success
}
}
Reithの:
あなたは(クライアント)のCSVコンテンツを期待している場合、クライアントは合格しなければならないtext/csv
ようAccept
ではないヘッダーContent-Type
。