博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
http://jadethao.iteye.com/blog/1926525
阅读量:6940 次
发布时间:2019-06-27

本文共 2195 字,大约阅读时间需要 7 分钟。

http://jadethao.iteye.com/blog/1926525

——————————————————————————————————————————————————————————————————

使用SpsringMVC,使用restEasy调试,controller请求设置如下: 
Java代码  
  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. }  
请求,debug跟踪list是返回值没有问题,但是前台页面报如下错误: 
Java代码  
  1. Response Status: 406 (Not Acceptable)  
Response RAW返回值如下,(前半部分) 
Xml代码  
  1. HTTP GET http://127.0.0.1:8080/onlineLibrary/rest/system/editTimeout/list  
  2. Host: 127.0.0.1:8080  
  3.   
  4.   
  5. 406 Not Acceptable  
  6. Date: Sat, 17 Aug 2013 11:01:07 GMT  
  7. Server: Apache-Coyote/1.1  
  8. Content-Length: 1067  
  9. Content-Type: text/html;charset=utf-8  
  10. <html><head><title>Apache Tomcat/7.0.34 - Error report</title><style>  
后台提示错误: 
Java代码  
  1. 2013-08-17 19: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: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: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-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问题解决。
  •  (762.1 KB)
  • 下载次数: 594
  •  (226.8 KB)
  • 下载次数: 475

转载地址:http://mkinl.baihongyu.com/

你可能感兴趣的文章
python静态方法和类方法
查看>>
iOS实现地图半翻页效果--老代码备用参考
查看>>
走过电竞之路的程序员
查看>>
JQ 获取地址栏参数
查看>>
关于AFNetworking访问网络超时的设置
查看>>
让前端独立于后端进行开发,模拟数据生成器Mock.js
查看>>
微信公众平台开发—利用OAuth2.0获取微信用户基本信息
查看>>
golang遇到的win下读取txt字符乱码的问题
查看>>
Binary Search--二分查找
查看>>
《计算机图形学》2.1.6 三维观察设备 学习笔记
查看>>
QT在线
查看>>
以P2P网贷为例互联网金融产品如何利用大数据做风控?
查看>>
Polymer初探
查看>>
zprofiler三板斧解决cpu占用率过高问题(转载)
查看>>
深入浅出NIO Socket实现机制
查看>>
bzoj 1930: [Shoi2003]pacman 吃豆豆 [费用流]
查看>>
(数字IC)低功耗设计入门(三)——系统与架构级低功耗设计
查看>>
Dynamics CRM2016 新功能之从CRM APP中导出数据至EXCEL
查看>>
Android——推断Service是否已经启动
查看>>
subprocess模块
查看>>