我有一个jqgrid来填充来自后端的数据。直到控制器我有数据但它没有在网格中呈现。启用Fire bug说 NetworkError:406 Not Acceptable 。 我在我的类路径和调度程序aservlet中有 jackson-core-asl-1.x.jar 和 jackson-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;
}`
答案 0 :(得分:0)
我想在这里:
@RequestMapping(value = "/populateAddedDeviceGrid.html", headers="Accept=application/json", method = RequestMethod.POST)
//-------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
此处应使用headers
来代替produces
:
@RequestMapping(value = "/populateAddedDeviceGrid.html", produces={"application/json"} , method = RequestMethod.POST)