任何人都可以告訴我如何從控制器中獲取數據,將類型hashmap的數據返回給jqgrid?使用jqgrid以表格格式顯示數據
這是我試過的。它進入一個無限垂耳
$(document).ready(function(){
$("#datatable").jqGrid({
url:"${pageContext.request.contextPath}/employees",
cache: false,
colNames:["id","name","age","salary","address","laptop"],
colModel:[
{name:"id",index:"id", width:60},
{name:"name",index:"name", width:90},
{name:"age",index:"age", width:100},
{name:"salary",index:"salary", width:80, align:"right"},
{name:"address",index:"address", width:80,
align:"right"},
{name:"laptop",index:"laptop", width:80,align:"right"}
],
mtype: "GET",
rownumbers: true,
rownumWidth: 40,
gridview: true,
caption: "Hashmap Data"
});
});
控制器部分
@RequestMapping(value="/employees", method = RequestMethod.GET)
public ModelAndView listEmployees() {
Map<String, Object> model = new HashMap<String, Object>();
model.put("employees",
prepareListofBean(employeeService.listEmployeess()));
for (Entry<String, Object> entry : model.entrySet()) {
String key = entry.getKey().toString();
Object value = entry.getValue();
System.out.println("hello key, " + key + " value " + value);
}
return new ModelAndView("employeesList", model);
}
例如: 員工創造價值[1衝頭22 12234 USA是,6 ABC 25 23889 XYZ,是]
請人幫忙我在解決這個問題。 其給予解析錯誤:無效的XML消息
請告訴我們,AJAX調用的示例數據。 – juzraai
value [1 ram 22 12234 usa yes,6 abc 25 23889 xyz,yes] – abc