java org.springframework.http.MediaType中的标记字符“:”无效

niknxzdl  于 2023-02-21  发布在  Java
关注(0)|答案(1)|浏览(110)

我有一个基本的SpringBoot2.3.4.RELEASE应用程序。使用Spring初始化器,JPA,嵌入式Tomcat;
我想创建此MediaType

MediaType customMediaType = MediaType.parseMediaType("application/json; profile=http://realtime-listings.webservices.zpg.co.uk/docs/v2.0/schemas/listing/list.json");

在PostMan中可以正常工作,但在RestTemplate中不行

ERROR at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:175) 
- Servlet.service() for servlet [dispatcherServlet] in context with path [/zoopla] threw exception [common.exception.BusinessException: 
Invalid mime type "application/json; profile=http://test.com/docs/v2.0/schemas/listing/list.json": 
Invalid token character ':' in token "http://test.com/docs/v2.0/schemas/listing/list.json"
ilmyapht

ilmyapht1#

然后,如果postman允许,它就会被破坏,因为:在类型中无效。
参见RFC 6838和RFC 3986

相关问题