Jquery 使用jqgrid以表格格式显示数据
有人能告诉我如何从控制器获取数据,并将hashmap类型的数据返回到jqgrid中吗 这就是我尝试过的。它进入了一个无限的lopJquery 使用jqgrid以表格格式显示数据,jquery,spring-mvc,jqgrid,Jquery,Spring Mvc,Jqgrid,有人能告诉我如何从控制器获取数据,并将hashmap类型的数据返回到jqgrid中吗 这就是我尝试过的。它进入了一个无限的lop $(document).ready(function(){ $("#datatable").jqGrid({ url:"${pageContext.request.contextPath}/employees", cache: false, colNames:["id","name","age","salary"
$(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);
}
@RequestMapping(value=“/employees”,method=RequestMethod.GET)
公共模型和查看列表员工(){
映射模型=新的HashMap();
model.put(“员工”,
prepareListofBean(employeeService.listEmployeess());
for(条目:model.entrySet()){
String key=entry.getKey().toString();
对象值=entry.getValue();
System.out.println(“hello键,+key+“value”+value”);
}
返回新模型和视图(“employeesList”,模型);
}
例如:
员工价值[1 ram 22 12234美国是,6 abc 25 23889 xyz,是] 请有人帮我解决这个问题。
它的给定解析错误:无效的xml消息可能您缺少jqgrid选项中的
数据类型
键
检查您的url${pageContext.request.contextPath}/employees
返回什么?并在另一个选项datatype
根据默认值,datatype
的默认值是xml
尝试将其更改为
json
也许您缺少jqgrid选项中的数据类型
键
检查您的url${pageContext.request.contextPath}/employees
返回什么?并在另一个选项datatype
根据默认值,datatype
的默认值是xml
尝试将其更改为
json
请向我们展示该AJAX调用的示例数据。value[1 ram 22 12234 usa yes,6 abc 25 23889 xyz,yes]请向我们展示该AJAX调用的示例数据。value[1 ram 22 12234 usa yes,6 abc 25 23889 xyz,yes]在不转换为json的情况下,有没有可能做到这一点?这是文档中所说的,您可以在datatype中给出:定义填充网格的数据的预期格式。有效的选项有xml(我们期望xml格式的数据)、xmlstring(我们期望xml数据为字符串)、json(我们期望json格式的数据)、jsonstring(我们期望json数据为字符串)、local(我们期望客户端定义的数据(数组数据))、javascript(我们期望javascript为数据)、function(用于检索数据的自定义函数),或者clientSide通过数据数组手动加载数据。我已经尝试将数据类型同时作为xml和local提供。但是它显示的是一个没有数据的表。您的ajax调用确切返回什么?注释这里有没有可能不转换为json就可以这样做?这是文档中所说的,您可以在datatype中给出:定义填充网格的数据的预期格式。有效的选项有xml(我们期望xml格式的数据)、xmlstring(我们期望xml数据为字符串)、json(我们期望json格式的数据)、jsonstring(我们期望json数据为字符串)、local(我们期望客户端定义的数据(数组数据))、javascript(我们期望javascript为数据)、function(用于检索数据的自定义函数),或者clientSide通过数据数组手动加载数据。我已经尝试将数据类型同时作为xml和local提供。但是它显示的是一个没有数据的表。您的ajax调用确切返回什么?在这里发表评论