元問答欄目視頻美女
  1. 編程問答
  2. 答案列表

415是什麼錯誤碼

回答列表
http狀態碼:415。
出現415錯誤有一種情況是和請求報文中header的content-type有關。如果沒有設置這個,通常就會報415錯誤。所以可以注意看下,這裡是否已經配置了。
原因 請求頭中的content-type的作用是當年向伺服器發請求時,你需要告訴伺服器發送的數據是什麼類型,這樣伺服器才能去解析?
一般是前端發送數據給後台,後台不能識別,造成的。
比如json 字符串格式{「key」,「value」}
但是傳送過來的數據value,有引號的,但是key 一般都不帶的。
所以造成後台無法解析了。比較快捷的一種解決方式,在springmvc配置文件中加段配置即可:(需要導下fastjson 依賴包)。
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="com.alibaba.fastjson.support.spring.fastjsonhttpmessageconverter">
<property name="supportedmediatypes"value="application/json"/>
<property name="features">
<array>
<value>writemapnullvalue</value>
<value>writedateusedateformat</value>
</array>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
猜你喜歡
相關推薦