406 Not Acceptable 415 Unsupported Media Type Spring MVC consumes与produces

Java Restful服务实战:从设计原则到生产级配置 Restful是一种基于HTTP协议的资源建模与状态转移架构风格,其核心在于URI标识资源、动词表达操作、状态码传递语义。在Java生态中,Spring Boot通过@RestController、@PathVariable、ResponseEntity等组件将HTTP语义映射为可工程化的代码结构,但真实落地常因Jackson序列化规则、Spring MVC请求生命周期、Nginx反向代理透传等环节失配而引发400/406/500类问题。本文聚焦Java开发者高频踩坑场景,深入解析@RequestBody参 阅读详情

        引言:SpringWeb MVC框架在使用的过程中,有时候会出现请求结果报406 Not Acceptable 或者415 Unsupported Media Type的错误,现在学习下为什么报这个错误以及怎么解决。

     Http协议基础知识及概念:

    HTTP(HyperText Transport Protocol)是超文本传输协议的缩写,是客户端浏览器或其他程序与Web服务器之间的应用层通信协议,关于HTTP协议的详细内容请参考RFC2616。通常HTTP消息包括客户机向服务器的请求消息和服务器向客户机的响应消息,请求消息包含请求行,头信息,实体(可能为空),响应消息包含状态行,头信息,实体。HTTP的头域包括通用头,请求头,响应头和实体头四个部分。通用头域包含请求和响应消息都支持的头域,通用头域包含Cache-Control、Connection、Date、Pragma、Transfer-Encoding、Upgrade、Via。对通用头域的扩展要求通讯双方都支持此扩展,如果存在不支持的通用头域,一般将会作为实体头域处理。

  通用头域:

         Cache-Control头域  指定请求和响应遵循的缓存机制

         Keep-Alive  Keep-Alive功能使客户端到服务器端的连接持续有效,当出现对服务器的后继请求时,Keep-Alive功能避免了建立或者重新建立连接

        Date 表示消息发送的时间,时间的描述格式由rfc822定义。例如,Date:Mon,31Dec200104:25:57GMT。Date描述的时间表示世界标准时,换算成本地时间,需要知道用户所在的时区

       Pragma 用来包含实现特定的指令,最常用的是Pragma:no-cache。在HTTP/1.1协议中,它的含义和Cache-Control:no-cache相同

   请求头域:

      请求头域可能包含下列字段Accept、Accept-Charset、Accept-Encoding、Accept-Language、Authorization、From、Host、If-Modified-Since、If-Match、If-None-Match、If-Range、If-Range、If-Unmodified-Since、Max-Forwards、Proxy-Authorization、Range、Referer、User-Agent。对请求头域的扩展要求通讯双方都支持,如果存在不支持的请求头域,一般将会作为实体头域处理。

  响应头域:

    响应头域允许服务器传递不能放在状态行的附加信息,这些域主要描述服务器的信息和Request-URI进一步的信息。响应头域包含Age、Location、Proxy-Authenticate、Public、Retry-After、Server、Vary、Warning、WWW-Authenticate。

  实体头域:

    请求消息和响应消息都可以包含实体信息,实体信息一般由实体头域和实体组成。实体头域包含关于实体的原信息,实体头包括Allow、Content-Base、Content-Encoding、Content-Language、Content-Length、Content-Location、Content-MD5、Content-Range、Content-Type、Etag、Expires、Last-Modified、extension-header。extension-header允许客户端定义新的实体头,但是这些域可能无法被接受方识别。实体可以是一个经过编码的字节流,它的编码方式由Content-Encoding或Content-Type定义,它的长度由Content-Length或Content-Range定义。

    Http协议消息头 Content-Type和Accept

    Http协议的通信标准可以在RFC2616文件中有详细的说明,说明如下:

    Accept

14.1 Accept

   The Accept request-header field can be used to specify certain media
   types which are acceptable for the response. Accept headers can be
   used to indicate that the request is specifically limited to a small
   set of desired types, as in the case of a request for an in-line
   image.

       Accept         = "Accept" ":"
                        #( media-range [ accept-params ] )

       media-range    = ( "*/*"
                        | ( type "/" "*" )
                        | ( type "/" subtype )
                        ) *( ";" parameter )
       accept-params  = ";" "q" "=" qvalue *( accept-extension )
       accept-extension = ";" token [ "=" ( token | quoted-string ) ]

   The asterisk "*" character is used to group media types into ranges,
   with "*/*" indicating all media types and "type/*" indicating all
   subtypes of that type. The media-range MAY include media type
   parameters that are applicable to that range.

   Each media-range MAY be followed by one or more accept-params,
   beginning with the "q" parameter for indicating a relative quality
   factor. The first "q" parameter (if any) separates the media-range
   parameter(s) from the accept-params. Quality factors allow the user
   or user agent to indicate the relative degree of preference for that
   media-range, using the qvalue scale from 0 to 1 (section 3.9). The
   default value is q=1.

      Note: Use of the "q" parameter name to separate media type
      parameters from Accept extension parameters is due to historical
      practice. Although this prevents any media type parameter named
      "q" from being used with a media range, such an event is believed
      to be unlikely given the lack of any "q" parameters in the IANA
      media type registry and the rare usage of any media type
      parameters in Accept. Future media types are discouraged from
      registering any parameter named "q".





Fielding, et al.            Standards Track                   [Page 100]
 
RFC 2616                        HTTP/1.1                       June 1999


   The example

       Accept: audio/*; q=0.2, audio/basic

   SHOULD be interpreted as "I prefer audio/basic, but send me any audio
   type if it is the best available after an 80% mark-down in quality."

   If no Accept header field is present, then it is assumed that the
   client accepts all media types. If an Accept header field is present,
   and if the server cannot send a response which is acceptable
   according to the combined Accept field value, then the server SHOULD
   send a 406 (not acceptable) response.

   A more elaborate example is

       Accept: text/plain; q=0.5, text/html,
               text/x-dvi; q=0.8, text/x-c

   Verbally, this would be interpreted as "text/html and text/x-c are
   the preferred media types, but if they do not exist, then send the
   text/x-dvi entity, and if that does not exist, send the text/plain
   entity."

   Media ranges can be overridden by more specific media ranges or
   specific media types. If more than one media range applies to a given
   type, the most specific reference has precedence. For example,

       Accept: text/*, text/html, text/html;level=1, */*

   have the following precedence:

       1) text/html;level=1
       2) text/html
       3) text/*
       4) */*

   The media type quality factor associated with a given type is
   determined by finding the media range with the highest precedence
   which matches that type. For example,

       Accept: text/*;q=0.3, text/html;q=0.7, text/html;level=1,
               text/html;level=2;q=0.4, */*;q=0.5

   would cause the following values to be associated:

       text/html;level=1         = 1
       text/html                 = 0.7
       text/plain                = 0.3



Fielding, et al.            Standards Track                   [Page 101]
 
RFC 2616                        HTTP/1.1                       June 1999


       image/jpeg                = 0.5
       text/html;level=2         = 0.4
       text/html;level=3         = 0.7

      Note: A user agent might be provided with a default set of quality
      values for certain media ranges. However, unless the user agent is
      a closed system which cannot interact with other rendering agents,
      this default set ought to be configurable by the user.

详细的中文大家可以网上翻译,大致的意思就是Accept请求头域可以被用来指定响应可接受的媒体类型,Accept请求头域用来表明请求被明确地限制到一个小的需要的类型集合内,正如一个请求内嵌图片的情况。在指定格式的同时还可以通过q参数指定权重。

406 Not Acceptable

The resource identified by the request is only capable of generating
   response entities which have content characteristics not acceptable
   according to the accept headers sent in the request.

   Unless it was a HEAD request, the response SHOULD include an entity
   containing a list of available entity characteristics and location(s)
   from which the user or user agent can choose the one most
   appropriate. The entity format is specified by the media type given
   in the Content-Type header field. Depending upon the format and the
   capabilities of the user agent, selection of the most appropriate
   choice MAY be performed automatically. However, this specification
   does not define any standard for such automatic selection.

      Note: HTTP/1.1 servers are allowed to return responses which are
      not acceptable according to the accept headers sent in the
      request. In some cases, this may even be preferable to sending a
      406 response. User agents are encouraged to inspect the headers of
      an incoming response to determine if it is acceptable.

   If the response could be unacceptable, a user agent SHOULD
   temporarily stop receipt of more data and query the user for a
   decision on further actions.

    大致的意思是请求指定的资源生产的带有内容的响应实体特性根据请求中发送来的Accept头域是不可接受的。如果响应不能被接受,客户端应该临时停止接受更多的数据并且为用户查询更进一步操作的决定。简而言之就是response设置的content-type不在请求头Accept指定的范围内。

415 Unsupported Media Type

The server is refusing to service the request because the entity of
   the request is in a format not supported by the requested resource
   for the requested method.

大致的意思是服务器正在拒绝为请求服务,因为请求的实体的格式不被请求的资源的方法支持,简而言之就是服务器的处理方法不支持请求实体中的content-type类型。

SpringMVC consumes与produces

    consumes

    RequestMapping注解中参数,源码注解如下:

/**
	 * The consumable media types of the mapped request, narrowing the primary mapping.
	 * <p>The format is a single media type or a sequence of media types,
	 * with a request only mapped if the {@code Content-Type} matches one of these media types.
	 * Examples:
	 * <pre class="code">
	 * consumes = "text/plain"
	 * consumes = {"text/plain", "application/*"}
	 * </pre>
	 * Expressions can be negated by using the "!" operator, as in "!text/plain", which matches
	 * all requests with a {@code Content-Type} other than "text/plain".
	 * <p><b>Supported at the type level as well as at the method level!</b>
	 * When used at the type level, all method-level mappings override
	 * this consumes restriction.
	 * @see org.springframework.http.MediaType
	 * @see javax.servlet.http.HttpServletRequest#getContentType()
	 */
	String[] consumes() default {};

大致的意思是映射的请求可消费的媒体类型,缩小基本的映射。格式为一个或者一系列的媒体类型,只有请求的content-type匹配上这些媒体类型中的一个这个请求才算映射上了。

Spring MVC中,在从HandlerMapping中找到一个对应的处理链的时候,会检查该配置。在RequestMappingInfoHandlerMapping中handleNoMatch方法中有如下代码:

if (helper.hasConsumesMismatch()) {
			Set<MediaType> mediaTypes = helper.getConsumableMediaTypes();
			MediaType contentType = null;
			if (StringUtils.hasLength(request.getContentType())) {
				try {
					contentType = MediaType.parseMediaType(request.getContentType());
				}
				catch (InvalidMediaTypeException ex) {
					throw new HttpMediaTypeNotSupportedException(ex.getMessage());
				}
			}
			throw new HttpMediaTypeNotSupportedException(contentType, new ArrayList<MediaType>(mediaTypes));
		}

在没有匹配上的时候会抛出HttpMediaTypeNotSupportedException,而这个异常会被Spring MVC在最后DefaultHandlerExceptionResolver中封装为415错误码的异常页面,源码如下:

/**
	 * Handle the case where no {@linkplain org.springframework.http.converter.HttpMessageConverter message converters}
	 * were found for the PUT or POSTed content.
	 * <p>The default implementation sends an HTTP 415 error, sets the "Accept" header,
	 * and returns an empty {@code ModelAndView}. Alternatively, a fallback view could
	 * be chosen, or the HttpMediaTypeNotSupportedException could be rethrown as-is.
	 * @param ex the HttpMediaTypeNotSupportedException to be handled
	 * @param request current HTTP request
	 * @param response current HTTP response
	 * @param handler the executed handler
	 * @return an empty ModelAndView indicating the exception was handled
	 * @throws IOException potentially thrown from response.sendError()
	 */
	protected ModelAndView handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
			HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {

		response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
		List<MediaType> mediaTypes = ex.getSupportedMediaTypes();
		if (!CollectionUtils.isEmpty(mediaTypes)) {
			response.setHeader("Accept", MediaType.toString(mediaTypes));
		}
		return new ModelAndView();
	}

返回的错误页面如下: 

produces

requestMapping注解参数,注释如下:

/**
	 * The producible media types of the mapped request, narrowing the primary mapping.
	 * <p>The format is a single media type or a sequence of media types,
	 * with a request only mapped if the {@code Accept} matches one of these media types.
	 * Examples:
	 * <pre class="code">
	 * produces = "text/plain"
	 * produces = {"text/plain", "application/*"}
	 * produces = "application/json; charset=UTF-8"
	 * </pre>
	 * <p>It affects the actual content type written, for example to produce a JSON response
	 * with UTF-8 encoding, {@code "application/json; charset=UTF-8"} should be used.
	 * <p>Expressions can be negated by using the "!" operator, as in "!text/plain", which matches
	 * all requests with a {@code Accept} other than "text/plain".
	 * <p><b>Supported at the type level as well as at the method level!</b>
	 * When used at the type level, all method-level mappings override
	 * this produces restriction.
	 * @see org.springframework.http.MediaType
	 */
	String[] produces() default {};

匹配的请求资源可生产的媒体类型,限制基本的映射。格式是一个或者一系列的媒体类型,只有一个请求的Accept头中的媒体类型匹配到这个参数指定的媒体类型中的至少一个,才算请求匹配上了。这个参数还影响了实际的响应实体的类型。同理,在SpringMVC中也会检查该配置参数与实际请求的匹配情况,也是在RequestMappingInfoHandlerMapping中handleNoMatch方法中有如下代码:

if (helper.hasProducesMismatch()) {
			Set<MediaType> mediaTypes = helper.getProducibleMediaTypes();
			throw new HttpMediaTypeNotAcceptableException(new ArrayList<MediaType>(mediaTypes));
		}

在DefaultHandlerExceptionResolver中也会封装该异常为406结果页面

/**
	 * Handle the case where no {@linkplain org.springframework.http.converter.HttpMessageConverter message converters}
	 * were found that were acceptable for the client (expressed via the {@code Accept} header.
	 * <p>The default implementation sends an HTTP 406 error and returns an empty {@code ModelAndView}.
	 * Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotAcceptableException
	 * could be rethrown as-is.
	 * @param ex the HttpMediaTypeNotAcceptableException to be handled
	 * @param request current HTTP request
	 * @param response current HTTP response
	 * @param handler the executed handler
	 * @return an empty ModelAndView indicating the exception was handled
	 * @throws IOException potentially thrown from response.sendError()
	 */
	protected ModelAndView handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex,
			HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {

		response.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE);
		return new ModelAndView();
	}

【项目实战】常见的HTTP状态码(406 Not Acceptable) 406 (Not Acceptable) 的 HTTP 状态码HTTP状态码406 ,即Not Acceptable。 阅读详情

相关推荐

MATLAB图像去噪实战:如何用巴特沃斯滤波器完美去除横条纹(附完整代码)

本文详细介绍了如何使用MATLAB中的巴特沃斯滤波器有效去除图像中的横条纹噪声。通过频域分析和滤波处理,结合完整的代码示例,帮助读者掌握从噪声分析到参数优化的全流程技术,实现高质量的图像去噪效果。

weixin_30566063的博客 562

springmvc报错415 Unsupported Media Type

错误:在使用springmvc调后台的时候,有时会报这样的错误:415 Unsupported Media Type: 其实这个是因为我们在后台使用了@RequestBody,这个就是将json对象转为java对象的,但是我们前台传到后台的却不是json格式的字符串,所以就报错了 有几点需要注意的 1)ajax将json字符串传给后台使用@RequestBody,需要在ajax内指定发送给后台的数...

qq_40021661的博客 923

Aruba无线控制器实战:如何用Client Match优化企业办公区漫游(附SNR调优技巧)

本文深入解析了如何利用Aruba无线控制器的Client Match功能优化企业办公区无线漫游体验。通过实战配置,详细阐述了基于SNR(信噪比)的精细化调优策略,包括阈值设定、负载均衡与场景化参数调整,旨在解决终端粘滞、乒乓漫游等问题,实现智能、平滑的无缝漫游。

weixin_28318011的博客 228

记录一次Unsupported Media Type解决方案

笔者今天碰到一个问题,就是自身的一个接口被第三方的业务回调的时候出现了一个415的错误,也就是Unsupported Media Type。之后查了些资料,总结一下。 文章目录一、415是什么错误?二、两种解决办法三、顺便记录一下常见的媒体格式类型 一、415是什么错误? 对于当前请求的方法和所请求的资源,请求中提交的实体并不是服务器中所支持的格式,因此请求被拒绝。 也就是说第三方发给己方服务器参数格式和服务器所要求的的参数格式不一样,比如第三方传的是’application/x-www-form-.

qq_42697271的博客 2万+

详解Nacos集群搭建

在我们日常的开发当中,用的都是单点Nacos,这种模式,我们自己开发测试玩一玩还可以,但是到了企业的生产环境之下,你还这么玩的话,那肯定是要出大问题了。因为在企业当中,我们更加强调的是高可用,所以在企业的生产环境下,Nacos一定要做成个集群。

博客 1万+

TPAMI 2025新作LRFormer复现笔记:我的Windows 11 + RTX 4090配置全流程

本文详细记录了在Windows 11系统下使用RTX 4090显卡复现TPAMI 2025顶会论文LRTransformer的完整流程,包括硬件配置、系统优化、Python环境搭建及模型训练中的常见问题解决方案。特别针对Windows平台特有的路径管理、CUDA版本冲突和显存优化等关键技术细节提供了实用指南,帮助开发者高效完成环境搭建和模型训练。

weixin_29094301的博客 412

http请求报错:406 Not Acceptable的解决办法

406 Not Acceptable 表示用户代理(在大多数情况下是 Web 浏览器)请求了有效的资源,但请求包含一个特殊的 Accept- 标头,该标头向服务器指示有效响应只能包含特定类型的信息。如果上述两个方法都没有解决的话,你就去看你接口返回的数据,比如我的,我是返回的结果集,通过试错,我发现是我的结果集出现了问题,我的结果集进行了序列化。接口在返回结果集的时候出现了406的报错,但是返回String类型不会报错,正常返回。如果出现not found报错的话,就提高这个依赖的版本,可以改为。

渴望飞翔的小白 1万+

嵌入式状态机编程-QP状态机框架与常见状态机方法

状态机基本术语 现态:是指当前所处的状态。 条件:又称为“事件”,当一个条件被满足,将会触发一个动作,或者执行一次状态的迁移。 动作:条件满足后执行的动作。动作执行完毕后,可以迁移到新的状态,也可以仍旧保持原状态。动作不是必需的,当条件满足后,也可以不执行任何动作,直接迁移到新状态。 次态:条件满足后要迁往的新状态。“次态”是相对于“现态”而言的,“次态”一旦被激活,就转变成新的“现态”了。 传统有限状态机Fsm实现方法 如图,是一个定时计数器,计数器存在两种状态,一种为设置状态,一种为计时状态 设

qq_36969440的博客 9663

[SpringMVC 源码] 415 (Unsupported Media Type) 原因及解决方案

一、现象描述前端 ajax 方式调用 springmvc 接口时,返回 415 (Unsupported Media Type) 错误:前端代码:function fSave(url) { var obj = {}; obj['cateId'] = $("input[name=cateId]").val(); obj['cateName'] = $("input[name=ca

列苗 8110

ArcGIS Pro新手避坑:从OpenStreetMap导入路网到创建拓扑关系全流程

本文详细解析了ArcGIS Pro中从OpenStreetMap导入路网数据到创建拓扑关系的全流程,涵盖OSM数据特性、几何完整性检查、属性强化及拓扑关系构建等关键步骤。特别针对路网数据预处理、网络数据集配置和常见问题提供了实用解决方案,帮助GIS新手高效完成网络分析任务。

weixin_33670786的博客 514

2026华数杯 国际大学生数学建模竞赛 A题 如何防守直接任意球? 解题思路+模型分析+代码

2026华数杯 国际大学生数学建模竞赛 A题 如何防守直接任意球? 解题思路+模型分析+代码。基于视频数据重构进球轨迹,建立空间坐标系并进行曲线拟合,推算初始速度。建立"香蕉球"、"电梯球"、"落叶球"三种典型直接任意球轨迹的动力学模型,分析C罗进球的类型。针对C罗这类强力球员的直接任意球,提出人墙排布策略和守门员防守策略。

YOLO 663

关于HTTP请求返回415(Unsupported Media Type) 不支持的类型异常-定位问题

关于HTTP请求返回415(Unsupported Media Type) 不支持的类型异常-定位问题

m0_59278919的博客 3万+

996引擎 - 读写变量性能测试

单轮100万次读写,取3轮平均耗时(毫秒),有效读取率均为100%,数值越小性能越优。

灵台方寸山斜月三星洞 244

测试反馈Unsupported Media Type的解决方法

今天在Postman进行测试的时候,反馈报错"Unsupported Media Type",即不支持媒体类型

qq_63192977的博客 3202

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

http 415 unsupported media type 多种原因解决方案

http 415 unsupported media type 报错解决方案

weixin_45956631的博客 2万+

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

HTTP 415 错误 – 不支持的媒体类型(Unsupported media type)

前段时间在使用@RequestBody注解的时候遇到了一个以前没遇到过的错误,HTTP 415  Unsupported media type? 这个是个什么鬼,@ResponseBody可以正常工作而一使用@RequestBody来进行交互就会报这个错误。一直请求不到Controller,我开始总以为是路径或者json格式不对的问题,上网查资料大多也说的是这个问题。可是我已经写了 data :

13万+

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Http状态码406(Not Acceptable) 错误问题解决方法

状态码406:HTTP协议状态码的一种,表示无法使用请求的内容特性来响应请求的网页。说白了就是后台的返回结果前台无法解析就报406错误。 示例代码中请求代码,后台代码均正常,且有返回信息。如下图: $.ajax({ url:'http://localhost:8080/findDsrwByDsrwid', type : 'post', ......

疯狂的蜗牛 35万+

springMVC 415 (Unsupported Media Type)

js代码 $.ajax({ url:"/pblog/article/add", type:"POST", contentType:"application/json", dataType:"json", data: JSON.stringify(articleVO),

记录 5035

HTTP 415错误状态码

HTTP 415错误状态码是指"Unsupported Media Type"(不支持的媒体类型)。这通常发生在客户端向服务器发送请求时,请求中包含的媒体类型(例如Content-Type头部)不被服务器支持或识别的情况下。

qq_44327851的博客 3万+

postman报415(Unsupported Media Type)不支持的类型异常

postman报415(Unsupported Media Type)不支持的类型异常

weixin_64854388的博客 3038

Jmeter-请求接口时返回415状态码,提示“ Unsupported Media Type“

如图,在通过Jmeter请求接口时,返回了415状态码,在响应数据中提示"Unsupported Media Type" http 415状态码是指的对于当前请求的方法和所请求的资源,请求中提交的实体并不是服务器中所支持的格式,因此请求被拒绝。 所以就要去看请求头中的content-type填写是否正确 请求头中的Content-Type的值是"application/x-www-form-urlencoded"但是返回的响应头中为"application/json",所以显然返回415.

wutrg1502的博客 1万+

HTTP响应的状态码415解决

原因与解决 HTTP响应返回415状态码,错误信息为“Unsupported Media Type”,也就是服务器无法处理请求附带的媒体格式, 解决方法就是在请求头中加入Content-Type指定媒体格式类型(也可以理解成编码格式)。 另外在请求头中添加Accept可指定客户端能接受的内容类型。 解决415状态码,可以通过在请求头中设置Content-Type对应的媒体类型,比如: 在请求头中添加: "Content-Type":"application/json" ...

skh2015java的博客 5万+

Postman报错Unsupported Media Type

报错信息如下: { "timestamp": "2018-12-06T01:37:11.184+0000", "status": 415, "error": "Unsupported Media Type", "message": "Content type 'text/plain;charset=UTF-8' not supported", "path": "/testgu/ycyzha...

疯猫 9万+

http 415 错误

HTTP响应返回415状态码,错误信息为“Unsupported Media Type”,也就是服务器无法处理请求附带的媒体格式。比如服务端可接收的格式为json,客户端发出的报文header 中”content-type“为text。加上请求头后,可能会触发option操作,后台应允许option请求,同时应在其返回信息中增加部分头信息,尤其是允许客户端设置”Content-Type“头信息。在请求头中添加: "Content-Type":"application/json"

海纳GIS专栏 8828

415 Unsupported Media Type异常

由于@RequestBody和请求格式不匹配导致的415 Unsupported Media Type异常解决

weixin_73077810的博客 1774

HTTP请求415错误 – 不支持的媒体类型(Unsupported media type)

HTTP请求415错误 – 不支持的媒体类型(Unsupported media type) 通常有以下情况: 1:检查你的 http 请求头信息,比如 因为 User-Agent 被服务器设置 拒绝请求了;     比如你写的的爬虫,就很有可能因为没有伪装成浏览器,被拒绝请求     user-agent 详情 2:查看你的 http 请求方法,以及服务器端的设置    比如:有一个...

weixin_34128839的博客 1万+
上一篇: SpringMVC API缓存 LastModified的实现总结
下一篇: MyBatis 高级映射与懒加载
tony_code_2017
博客等级 码龄9年 34粉丝 58原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值