前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Invalid mime type \"application-json; charset=utf-8;charset=ISO-8859-1\": does not contain '/'

Invalid mime type \"application-json; charset=utf-8;charset=ISO-8859-1\": does not contain '/'

作者头像
高大北
发布2022-12-02 11:51:23
2.3K0
发布2022-12-02 11:51:23
举报
文章被收录于专栏:java架构计划训练营
  • 全网能够搜索到的解决方式

  • 原代码
代码语言:javascript
复制
package com.bp.feign;
 
import com.alibaba.fastjson.JSONObject;
import com.bp.entity.dpt.UnifiedDataReq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
 
@FeignClient(name = "unifiedData",url = "${unifiedDataService.newUrl}")
public interface UnifiedDataGatewayClient {
    @PostMapping(value = "/organization/organizations/search")
    JSONObject getDptData(@RequestBody UnifiedDataReq unifiedDataReq, @RequestHeader("Authorization") String accessToken, @RequestHeader("Content-Type") String contentType);
}
  • 修改后的代码:

@PostMapping(value = “/organization/organizations/search”, consumes = “application/json”, produces = “application/json”)

代码语言:javascript
复制
package com.bp.feign;
 
import com.alibaba.fastjson.JSONObject;
import com.bp.entity.dpt.UnifiedDataReq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
 
@FeignClient(name = "unifiedData",url = "${unifiedDataService.newUrl}")
public interface UnifiedDataGatewayClient {
    @PostMapping(value = "/organization/organizations/search", consumes = "application/json", produces = "application/json")
    JSONObject getDptData(@RequestBody UnifiedDataReq unifiedDataReq, @RequestHeader("Authorization") String accessToken, @RequestHeader("Content-Type") String contentType);
}
代码语言:javascript
复制
    @Bean("requestInterceptor")
    public RequestInterceptor requestInterceptor(){
        return template -> {
            ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
            if(attributes!=null){
                HttpServletRequest request = attributes.getRequest();
                if (null == request){
                    return;
                }
                log.info(request.getHeaderNames().toString());
                template.header("token", request.getHeader("token"));
            }else {
                log.warn("requestInterceptor获取Header空指针异常");
            }
        };
    }
  • 解决前
  • 解决后
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-11-28 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档