开发者社区> 问答> 正文

关于controller接收json串的问题

js:
        function aaa(){     
         var rows = $('#dg').datagrid('getSelections');
        location.href="exportbus.do?swBus="+JSON.stringify(rows);
        }
        java后台:
@RequestMapping("/exportbus.do")


@ResponseBody
 public void exportbus(@RequestBody SwBus[] swBus,HttpServletRequest request,HttpServletResponse response)throws Exception{
 try {
 System.out.println("===========");
 HSSFWorkbook workbook=new HSSFWorkbook();
 String titles[] = {"企业名称","组织机构代码"};
控制台报错:
DEBUG - Looking up handler method for path /exportbus.do
 DEBUG - Returning handler method [public void com.ufgov.controller.SwBusController.exportbus(com.ufgov.model.SwBus[],javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]
 DEBUG - Returning cached instance of singleton bean 'swBusController'
 DEBUG - Last-Modified value for [/fs/exportbus.do] is: -1
 DEBUG - Resolving exception from handler [public void com.ufgov.controller.SwBusController.exportbus(com.ufgov.model.SwBus[],javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported
 DEBUG - Resolving exception from handler [public void com.ufgov.controller.SwBusController.exportbus(com.ufgov.model.SwBus[],javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported
 DEBUG - Resolving exception from handler [public void com.ufgov.controller.SwBusController.exportbus(com.ufgov.model.SwBus[],javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported
 DEBUG - Null ModelAndView returned to DispatcherServlet with name 'SpringMVC': assuming HandlerAdapter completed request handling

展开
收起
杨冬芳 2016-07-05 11:24:16 2917 0
1 条回答
写回答
取消 提交回答
  • IT从业

    http 415错误是请求错误,首先你检查一下你的代码有问题没,比如大小写!!以及exportbus.do存在么?去swBusController里好好看一下其次,断点测试各个数据!!看看数据传输的对不对!一步一步调!程序断点或者用浏览器调!检查exportbus.do里返回的值!
    org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported 格式不支持
    application/octet-stream 是发送二进制数据时使用的

    2019-07-17 19:51:19
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
相关产品:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载