<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'jgGird.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/css/jquery-ui-1.8.2.custom.css" />
<script type="text/javascript" src="<%=path %>/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="<%=path %>/js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript" src="<%=path %>/js/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="<%=path %>/js/jquery.jqGrid.min.js"></script>
<script type="text/javascript">
$(function()
{
$("#gridTable").jqGrid({
url:'listProduct',
dataType:'json',
colNames:['商品编号','商品名称','商品价格'],
colModel:[
{name:'id',index:'id',width:100},
{name:'pname',index:'pname',width:100},
{name:'price',index:'price',width:100,}
],
pager:'#pager2',
rowNum:-1,
rowList:[10,20,30],
sortname:'id',
sortorder:'desc',
viewrecords:true,
caption:'商品总览'
}).navGrid("#pager2",{edit:false,add:false,del:false,search:false});
});
</script>
</head>
<body>
<table id="gridTable"></table>
<div id="pager2"></div>
</body>
</html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'jgGird.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/css/jquery-ui-1.8.2.custom.css" />
<script type="text/javascript" src="<%=path %>/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="<%=path %>/js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript" src="<%=path %>/js/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="<%=path %>/js/jquery.jqGrid.min.js"></script>
<script type="text/javascript">
$(function()
{
$("#gridTable").jqGrid({
url:'listProduct',
dataType:'json',
colNames:['商品编号','商品名称','商品价格'],
colModel:[
{name:'id',index:'id',width:100},
{name:'pname',index:'pname',width:100},
{name:'price',index:'price',width:100,}
],
pager:'#pager2',
rowNum:-1,
rowList:[10,20,30],
sortname:'id',
sortorder:'desc',
viewrecords:true,
caption:'商品总览'
}).navGrid("#pager2",{edit:false,add:false,del:false,search:false});
});
</script>
</head>
<body>
<table id="gridTable"></table>
<div id="pager2"></div>
</body>
</html>
解决方案 »
- web中如何实现打印功能
- js字符串替换的问题
- dwr.engine为空或不是对象 高手们我在线等
- 求救!javascript动态生成图像元素,在ie中出图,但在FF中没反应,请高手帮忙,谢谢!多谢!
- 用js提示下载ActiveX控件--如何实现
- 下拉菜单按照姓名拼音顺序排列?
- 如何判断一组checkbox,一个也没有选中?
- 怎么用javasript判断一个图片的宽度,如果宽度小于一个数值,就以正常显示,大于就设置宽度width属性,谢谢!
- 求自动设置默认页的程序,立即给分!
- 高手帮忙!关于超链接!
- 关于判断iframe载入的一个问题
- JS怎么获取客户端物理网卡的的MAC地址,而不是获取虚拟或PPPOE的MAC地址呢?
public void listProductJson(HttpServletRequest request,
HttpServletResponse response) throws IOException{
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
System.out.println("OK");
List<Product> products = productService.find("from Product");
JSONArray json = new JSONArray();
for(Product product:products){
JSONObject temp = new JSONObject();
temp.put("id", product.getId());
temp.put("pname", product.getPname());
temp.put("price", product.getPrice());
json.add(temp);
}
out.print(json);
}