LigerUI java SSH小例子

1、新建web project

2、ssh框架 加入到项目中去(这里不介绍,网上搜索)

3、struts2配置 http://www.cnblogs.com/istianyu/archive/2013/05/22/3093768.html

4、jsp页面 index2.jsp

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 3 <%@ taglib prefix="s" uri="/struts-tags"%>
 4 
 5 <%
 6 String path = request.getContextPath();
 7 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 8 %>
 9 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
10 <html>
11   <head>
12     <title>My JSP 'index2.jsp' starting page</title>
13   </head>
14     <link href="lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
15     <link href="lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
16     <link href="lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
17     <script src="lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script> 
18     <script src="lib/ligerUI/js/core/base.js" type="text/javascript"></script> 
19     <script src="lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
20     <script src="lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
21     <script src="lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
22     <script src="lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
23     <script src="lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
24     <body>
25     <div id="liger-grid"></div>
26 <script type="text/javascript">
27     $(function(){
28         
29         $("#liger-grid").ligerGrid({
30             height:'auto',
31             width:'600px',
32             columns: [
33                 { display: 'id', name: 'studentId', align: 'center'}, 
34                         { display: '姓名', name: 'studentName'}, 
35                         { display: '年龄', name: 'studentAge'},
36                         { display: '年级', name: 'classes.className',render:function(data){return data.classes.className==null? "无" : data.classes.className }}
37             ],
38             url: 'student.action',
39             pageSize:5,
40             rownumbers:true,
41             resizable :true,
42             dataAction:'local',
43                 toolbar: { items: [
44                 { text: '增加', click: opt, icon: 'add' },
45                 { text: '修改', click: opt, icon: 'modify' },
46                 { text: '删除', click: opt, icon: 'delete' }
47                 ]
48                 }
49         });
50         
51         function opt(type){
52             var typeValue = type.icon;
53             var manager = $("#liger-grid").ligerGetGridManager();
54             var row = manager.getSelectedRow();
55             
56             switch (typeValue) {
57             case "add":
58                 $.ligerDialog.open({url: 'http://www.baidu.com',height: 350,width: 350});
59                 break;
60             case "modify":
61                 $.ligerDialog.open({url: 'update.jsp?studentId='+row.studentId,height: 450,width: 450});
62                 
63                 break;
64             case "delete":
65                  alert("您选择的是:" + row.studentId );
66                 
67                 break;
68             }
69         }
70     });
71 </script>
72     </body>
73 </html>

 

 

 

 

 

你可能感兴趣的:(java)