日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

SpringMVC异常报406 (Not Acceptable)的解决办法

發布時間:2025/7/14 javascript 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringMVC异常报406 (Not Acceptable)的解决办法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用SpsringMVC,使用restEasy調試,controller請求設置如下:?
Java代碼??
  • @RequestMapping(value="/list",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)??
  • @ResponseBody??
  • public?List<EditTimeout>?list(){??
  • ?????List<EditTimeout>?list?=?editImpl.selectAll();??
  • ????return?list;??
  • }??


  • 請求,debug跟蹤list是返回值沒有問題,但是前臺頁面報如下錯誤:?
    Java代碼??
  • Response?Status:?406?(Not?Acceptable)??


  • Response RAW返回值如下,(前半部分)?
    Xml代碼??
  • HTTP?GET?http://127.0.0.1:8080/onlineLibrary/rest/system/editTimeout/list??
  • Host:?127.0.0.1:8080??
  • ??
  • ??
  • 406?Not?Acceptable??
  • Date:?Sat,?17?Aug?2013?11:01:07?GMT??
  • Server:?Apache-Coyote/1.1??
  • Content-Length:?1067??
  • Content-Type:?text/html;charset=utf-8??
  • <html><head><title>Apache?Tomcat/7.0.34?-?Error?report</title><style>??


  • 后臺提示錯誤:?
    Java代碼??
  • 2013-08-17?19:01:03,116?DEBUG?org.springframework.web.servlet.DispatcherServlet?-Last-Modified?value?for?[/onlineLibrary/rest/system/editTimeout/list]?is:?-1??
  • 2013-08-17?19:01:07,606?DEBUG?org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver?-Resolving?exception?from?handler?[public?java.util.List<com.online.ol.filter.EditTimeout>?com.online.ol.filter.EditTimeoutContoller.list()]:?org.springframework.web.HttpMediaTypeNotAcceptableException:?Could?not?find?acceptable?representation??
  • 2013-08-17?19:01:07,680?DEBUG?org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver?-Resolving?exception?from?handler?[public?java.util.List<com.online.ol.filter.EditTimeout>?com.online.ol.filter.EditTimeoutContoller.list()]:?org.springframework.web.HttpMediaTypeNotAcceptableException:?Could?not?find?acceptable?representation??
  • 2013-08-17?19:01:07,681?DEBUG?org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver?-Resolving?exception?from?handler?[public?java.util.List<com.online.ol.filter.EditTimeout>?com.online.ol.filter.EditTimeoutContoller.list()]:?org.springframework.web.HttpMediaTypeNotAcceptableException:?Could?not?find?acceptable?representation??




  • 引起的原因:?
    ?? 由于設置了@ResponseBody,要把對象轉換成json格式,缺少轉換依賴的jar包,故此錯。?
    解決辦法:?
    ?? 加入依賴的jar,jackson-core-asl-1.9.12.jar,jackson-mapper-asl-1.9.12.jar問題解決。
    • jackson-mapper-asl-1.9.12.jar?(762.1 KB)
    • 下載次數: 2536
    • jackson-core-asl-1.9.12.jar?(226.8 KB)
    • 下載次數: 2052

    轉載于:https://www.cnblogs.com/ThinkVenus/p/6786746.html

    總結

    以上是生活随笔為你收集整理的SpringMVC异常报406 (Not Acceptable)的解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。