【问题标题】:NetworkError: 406 Not Acceptable for jqgrid网络错误:jqgrid 不接受 406
【发布时间】:2014-07-09 11:37:29
【问题描述】:

我有一个 jqgrid 来填充来自后端的数据。直到控制器我有数据,但它没有在网格中呈现。启用 Fire 错误说 NetworkError: 406 Not Acceptable。 我的类路径和调度程序 aservlet 中有 jackson-core-asl-1.x.jarjackson-mapper-asl-1.x.jar。 我还尝试根据解决方案之一更改标头为 headers="Accept=application/json"。我正在使用 SPring4。以下是我在控制器中的代码。

`

@RequestMapping(value = "/populateAddedDeviceGrid.html", headers="Accept=application/json", method = RequestMethod.POST)
    public @ResponseBody
    GridPojo populateAddedDeviceGrid(HttpServletRequest request, GridPojo gridPojo) {
        System.out.println("Enetering DeviceMasterController-->populateAddedDeviceGrid (POST)");

        List<DeviceMaster> deviceMasterList = new ArrayList<DeviceMaster>();

        try {
            deviceMasterList = deviceMasterService.getAllDeviceMaster();


            gridPojo.setGridData(deviceMasterList.toArray());
            gridPojo.setRows(deviceMasterList.size());
            gridPojo.setRecords(deviceMasterList.size());

        } catch (Exception e) {
            e.printStackTrace();
        }
        return gridPojo;
    }` 

【问题讨论】:

    标签: jquery ajax jqgrid http-status-code-406


    【解决方案1】:

    我想在这里:

    @RequestMapping(value = "/populateAddedDeviceGrid.html", headers="Accept=application/json", method = RequestMethod.POST)
    //-------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    

    这里应该使用headers 而不是produces,如下所示:

    @RequestMapping(value = "/populateAddedDeviceGrid.html", produces={"application/json"} , method = RequestMethod.POST)
    

    【讨论】:

    • 它没有解决我的问题,我尝试使用 @RequestMapping(value = "/populateAddedDeviceGrid.html",produces="application/json",method = RequestMethod.POST) 。但仍然给我 406 http 错误
    猜你喜欢
    • 2013-12-07
    • 1970-01-01
    • 1970-01-01
    • 2015-03-17
    • 1970-01-01
    • 1970-01-01
    • 2017-04-08
    • 2013-12-18
    • 1970-01-01
    相关资源
    最近更新 更多