baidu_28530445 2015-05-27 08:35 采纳率: 0%
浏览 3664

关于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

jsp页面直接415

  • 写回答

2条回答

  • 生活没有if-else 2015-05-27 09:24
    关注
    1. http 415错误是请求错误,首先你检查一下你的代码有问题没,比如大小写!!以及exportbus.do存在么?去swBusController里好好看一下
    2. 其次,断点测试各个数据!!看看数据传输的对不对!一步一步调!程序断点或者用浏览器调!
    3. 检查exportbus.do里返回的值!
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮