SPRINGMVC Exception 406 (not acceptable) solution

Source: Internet
Author: User
Tags apache tomcat

With SPSRINGMVC, using Resteasy debugging, the controller request is set as follows:

Java code
    1. @RequestMapping (value="/list", Method=requestmethod.get,produces=mediatype.application_json_value)
    2. @ResponseBody
    3. Public list<edittimeout> List () {
    4. list<edittimeout> list = Editimpl.selectall ();
    5. return list;
    6. }



Request, debug trace list is the return value no problem, but the foreground page reports the following error:

Java code
    1. Response Status: 406 (not acceptable)



Response Raw return value is as follows, (first half)

XML code
  1. HTTP GET Http://127.0.0.1:8080/onlineLibrary/rest/system/editTimeout/list
  2. host:127.0.0.1:8080
  3. 406 Not acceptable
  4. Date:sat, 11:01:07 GMT
  5. server:apache-coyote/1.1
  6. content-length:1067
  7. content-type:text/html; charset=utf-8
  8. <HTML><head><title>apache Tomcat/7.0.34-error Report< /title><style>



Background prompt Error:

Java code
  1. 2013-08-17 19:< Span class= "number" >01:03,116 debug  Org.springframework.web.servlet.dispatcherservlet -last-modified value  For [/onlinelibrary/rest/system/edittimeout/list] is: -1  
  2. 2013-08-17 19:< Span class= "number" >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  
  3. 2013-08-17 19:< Span class= "number" >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  
  4. 2013-08- : $,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





Cause of the cause:
Because the @responsebody is set, it is wrong to convert the object to JSON format, without the jar package for the conversion dependency.
Workaround:
Join the dependent Jar,jackson-core-asl-1.9.12.jar,jackson-mapper-asl-1.9.12.jar problem resolution.

SPRINGMVC Exception 406 (not acceptable) solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.