码迷,mamicode.com
首页 > 编程语言 > 详细

JavaWeb之ssm框架整合,用户角色权限管理

时间:2017-10-15 22:37:22      阅读:4085      评论:0      收藏:0      [点我收藏+]

标签:tpm   权限管理   doctype   grid   erro   nat   spring   test   href   

SSM框架整合

Spring

SpringMVC

MyBatis

导包:
1, spring
2, MyBatis
3, mybatis-spring
4, fastjson
5, aspectweaver----AspectJ框架
6, log4j-----打印日志信息
7, ojdbc6.jar
8, jstl.jar, standard.jar----标准标签库
9, commons-logging-1.2.jar

src下建立包结构

配置web.xml,spring-mvc.xml,spring-all.xml

建立表结构,使用PowerDesigner

前台页面,后台方法等。

技术分享

 

技术分享

 项目结构:

技术分享

技术分享

代码(引用,未完全实现):

配置文件:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://java.sun.com/xml/ns/javaee"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 5     id="WebApp_ID" version="3.0">
 6     
 7     <!-- 告诉web容器log4j的属性文件所在位置 -->
 8     <context-param>
 9         <param-name>log4jConfigLocation</param-name>
10         <param-value>classpath:conf/log4j.properties</param-value>
11     </context-param>
12     <listener>
13         <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
14     </listener>
15     
16     <!-- spring框架提供的字符编码过滤器 -->
17     <filter>
18         <filter-name>characterEncodingFilter</filter-name>
19         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
20         <init-param>
21             <param-name>encoding</param-name>
22             <param-value>UTF-8</param-value>
23         </init-param>
24         <init-param>
25             <param-name>forceEncoding</param-name>
26             <param-value>true</param-value>
27         </init-param>
28     </filter>
29     <filter-mapping>
30         <filter-name>characterEncodingFilter</filter-name>
31         <url-pattern>/*</url-pattern>
32     </filter-mapping>
33 
34     <!-- 加载Spring的配置文件 -->
35     <context-param>
36         <param-name>contextConfigLocation</param-name>
37         <param-value>classpath:conf/spring-config.xml</param-value>
38     </context-param>
39     <listener>
40         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
41     </listener>
42     
43     <!-- 加载SpringMVC的配置文件 -->
44     <servlet>
45         <servlet-name>springDispatcherServlet</servlet-name>
46         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
47         <init-param>
48             <param-name>contextConfigLocation</param-name>
49             <param-value>classpath:conf/spring-mvc.xml</param-value>
50         </init-param>
51         <load-on-startup>1</load-on-startup>
52     </servlet>
53     <servlet-mapping>
54         <servlet-name>springDispatcherServlet</servlet-name>
55         <url-pattern>*.do</url-pattern>
56     </servlet-mapping>
57 </web-app>
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://java.sun.com/xml/ns/javaee"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 5     id="WebApp_ID" version="3.0">
 6     
 7     <!-- 告诉web容器log4j的属性文件所在位置 -->
 8     <context-param>
 9         <param-name>log4jConfigLocation</param-name>
10         <param-value>classpath:conf/log4j.properties</param-value>
11     </context-param>
12     <listener>
13         <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
14     </listener>
15     
16     <!-- spring框架提供的字符编码过滤器 -->
17     <filter>
18         <filter-name>characterEncodingFilter</filter-name>
19         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
20         <init-param>
21             <param-name>encoding</param-name>
22             <param-value>UTF-8</param-value>
23         </init-param>
24         <init-param>
25             <param-name>forceEncoding</param-name>
26             <param-value>true</param-value>
27         </init-param>
28     </filter>
29     <filter-mapping>
30         <filter-name>characterEncodingFilter</filter-name>
31         <url-pattern>/*</url-pattern>
32     </filter-mapping>
33 
34     <!-- 加载Spring的配置文件 -->
35     <context-param>
36         <param-name>contextConfigLocation</param-name>
37         <param-value>classpath:conf/spring-config.xml</param-value>
38     </context-param>
39     <listener>
40         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
41     </listener>
42     
43     <!-- 加载SpringMVC的配置文件 -->
44     <servlet>
45         <servlet-name>springDispatcherServlet</servlet-name>
46         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
47         <init-param>
48             <param-name>contextConfigLocation</param-name>
49             <param-value>classpath:conf/spring-mvc.xml</param-value>
50         </init-param>
51         <load-on-startup>1</load-on-startup>
52     </servlet>
53     <servlet-mapping>
54         <servlet-name>springDispatcherServlet</servlet-name>
55         <url-pattern>*.do</url-pattern>
56     </servlet-mapping>
57 </web-app>
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:context="http://www.springframework.org/schema/context"
 5     xmlns:mvc="http://www.springframework.org/schema/mvc"
 6     xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
 7         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
 8         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
 9     
10     <!-- 配置扫描器 -->
11     <context:component-scan base-package="com.hanqi.controller" />
12     
13     <!-- 配置视图解析器 -->
14     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
15         <!-- <property name="prefix" value="/WEB-INF/"></property> -->
16         <property name="prefix" value="/"></property>
17         <property name="suffix" value=".jsp"></property>
18     </bean>
19     
20     <!-- 上传文件的解析器 -->
21     <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
22         <!-- 上传文件的总大小, 单位是b -->
23         <property name="maxUploadSize" value="10240000"></property>
24         <!-- 单个文件的上传大小限制, 单位是b -->
25         <property name="maxUploadSizePerFile" value="1000000"></property>
26         <!-- 默认字符集 -->
27         <property name="defaultEncoding" value="utf-8"></property>
28     </bean>
29     
30     <!-- 开启SpringMVC注解驱动 -->
31     <mvc:annotation-driven>
32         <!-- 改成false, 原因是在spring中默认使用的json格式的转换器是Jackson.jar中的转换器, 但实际开发中更受欢迎的是fastjson.jar -->
33         <mvc:message-converters register-defaults="false">
34             <bean class="org.springframework.http.converter.StringHttpMessageConverter" />
35             <bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" />
36             <bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter" />
37             <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
38             <bean id="fastJsonHttpMessagerConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
39                 <!-- 设置支持的媒体类型 -->
40                 <property name="supportedMediaTypes">
41                     <list>
42                         <value>text/html; charset=utf-8</value>
43                         <value>application/json; charset=utf-8</value>
44                     </list>
45                 </property>
46             </bean>
47         </mvc:message-converters>
48     </mvc:annotation-driven>
49 </beans>

src下:

model层实体类:

 1 package com.hanqi.model;
 2 
 3 public class SrUserRole {
 4     private Integer id;
 5     private Integer userid;
 6     private Integer roleid;
 7 
 8     public SrUserRole() {
 9         super();
10     }
11 
12     public SrUserRole(Integer id, Integer userid, Integer roleid) {
13         super();
14         this.id = id;
15         this.userid = userid;
16         this.roleid = roleid;
17     }
18 
19     public Integer getId() {
20         return id;
21     }
22 
23     public void setId(Integer id) {
24         this.id = id;
25     }
26 
27     public Integer getUserid() {
28         return userid;
29     }
30 
31     public void setUserid(Integer userid) {
32         this.userid = userid;
33     }
34 
35     public Integer getRoleid() {
36         return roleid;
37     }
38 
39     public void setRoleid(Integer roleid) {
40         this.roleid = roleid;
41     }
42 }
 1 package com.hanqi.model;
 2 
 3 public class SrRoleMenu {
 4     private Integer id;
 5     private Integer roleid;
 6     private Integer menuid;
 7 
 8     public SrRoleMenu(Integer id, Integer roleid, Integer menuid) {
 9         super();
10         this.id = id;
11         this.roleid = roleid;
12         this.menuid = menuid;
13     }
14 
15     public SrRoleMenu() {
16         super();
17     }
18 
19     public Integer getId() {
20         return id;
21     }
22 
23     public void setId(Integer id) {
24         this.id = id;
25     }
26 
27     public Integer getRoleid() {
28         return roleid;
29     }
30 
31     public void setRoleid(Integer roleid) {
32         this.roleid = roleid;
33     }
34 
35     public Integer getMenuid() {
36         return menuid;
37     }
38 
39     public void setMenuid(Integer menuid) {
40         this.menuid = menuid;
41     }
42 }
 1 package com.hanqi.model;
 2 
 3 public class SrRole {
 4     private Integer id;
 5     private String rolename;
 6     private String status;
 7     private boolean checked;
 8 
 9     public SrRole() {
10         super();
11     }
12 
13     public SrRole(Integer id, String rolename, String status) {
14         super();
15         this.id = id;
16         this.rolename = rolename;
17         this.status = status;
18     }
19 
20     public Integer getId() {
21         return id;
22     }
23 
24     public void setId(Integer id) {
25         this.id = id;
26     }
27 
28     public String getRolename() {
29         return rolename;
30     }
31 
32     public void setRolename(String rolename) {
33         this.rolename = rolename;
34     }
35 
36     public String getStatus() {
37         return status;
38     }
39 
40     public void setStatus(String status) {
41         this.status = status;
42     }
43 
44     public boolean getChecked() {
45         return checked;
46     }
47 
48     public void setChecked(boolean checked) {
49         this.checked = checked;
50     }
51 }
 1 package com.hanqi.model;
 2 
 3 public class SrMenu {
 4     private Integer id;
 5     private String menuname;
 6     private String url;
 7     private String icon;
 8     private String status;
 9     private Integer parentid;
10 
11     public SrMenu() {
12         super();
13     }
14 
15     public SrMenu(Integer id, String menuname, String url, String icon, String status) {
16         super();
17         this.id = id;
18         this.menuname = menuname;
19         this.url = url;
20         this.icon = icon;
21         this.status = status;
22     }
23 
24     public Integer getId() {
25         return id;
26     }
27 
28     public void setId(Integer id) {
29         this.id = id;
30     }
31 
32     public String getMenuname() {
33         return menuname;
34     }
35 
36     public void setMenuname(String menuname) {
37         this.menuname = menuname;
38     }
39 
40     public String getUrl() {
41         return url;
42     }
43 
44     public void setUrl(String url) {
45         this.url = url;
46     }
47 
48     public String getIcon() {
49         return icon;
50     }
51 
52     public void setIcon(String icon) {
53         this.icon = icon;
54     }
55 
56     public String getStatus() {
57         return status;
58     }
59 
60     public void setStatus(String status) {
61         this.status = status;
62     }
63 
64     public Integer getParentid() {
65         return parentid;
66     }
67 
68     public void setParentid(Integer parentid) {
69         this.parentid = parentid;
70     }
71 }

dao层接口:

 1 package com.hanqi.dao;
 2 
 3 import java.util.List;
 4 
 5 import com.hanqi.model.SrUser;
 6 
 7 public interface SrUserDao {
 8 
 9     SrUser login(SrUser srUser);
10 
11     int insertSrUser(SrUser srUser);
12 
13     List<SrUser> selectAll();
14 
15 }
 1 package com.hanqi.dao;
 2 
 3 import java.util.List;
 4 
 5 import com.hanqi.model.SrRole;
 6 
 7 public interface SrRoleDao {
 8 
 9     List<SrRole> selectAllRoles(String userid);
10 
11     List<SrRole> selectAll();
12 
13 }
 1 package com.hanqi.dao;
 2 
 3 import java.util.List;
 4 
 5 import com.hanqi.model.SrMenu;
 6 import com.hanqi.model.SrUser;
 7 
 8 public interface SrMenuDao {
 9 
10     List<SrMenu> selectMenus(SrUser currentUser);
11 
12 }

dao层实现方法:

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE mapper
 3   PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 4   "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 5 <mapper namespace="com.hanqi.dao.SrUserDao">
 6 
 7     <select id="login" parameterType="SrUser" resultType="SrUser">
 8         select * from Sr_User s 
 9         <where>
10             s.username=#{username} and s.password=#{password}
11         </where>
12     </select>
13     
14     <select id="selectAll" resultType="SrUser">
15         select * from sr_user
16     </select>
17     
18     <insert id="insertSrUser" parameterType="SrUser">
19         insert into sr_user values 
20         (testsq.nextval, #{username}, #{password}, #{realname}, #{status}, null)
21     </insert>
22 </mapper>
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE mapper
 3   PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 4   "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 5 <mapper namespace="com.hanqi.dao.SrRoleDao">
 6 
 7     <select id="selectAllRoles" resultType="SrRole">
 8         SELECT * FROM sr_role sr WHERE sr.id IN 
 9         (SELECT sur.roleid FROM sr_user_role sur WHERE sur.userid=#{userid})
10     </select>
11     
12     <select id="selectAll" resultType="SrRole">
13         select * from sr_role
14     </select>
15 </mapper>
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE mapper
 3   PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 4   "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 5 <mapper namespace="com.hanqi.dao.SrMenuDao">
 6 
 7     <select id="selectMenus" parameterType="SrUser" resultType="SrMenu">
 8         SELECT * FROM SR_MENU SM
 9         WHERE SM.ID IN (SELECT SRM.MENUID
10         FROM SR_ROLE_MENU SRM
11         WHERE SRM.ROLEID = (SELECT SUR.ROLEID
12         FROM SR_USER_ROLE SUR
13         WHERE SUR.USERID = #{id}))
14     </select>
15 
16 </mapper>

controller层控制器:

 1 package com.hanqi.controller;
 2 
 3 import java.util.ArrayList;
 4 import java.util.List;
 5 
 6 import org.springframework.beans.factory.annotation.Autowired;
 7 import org.springframework.stereotype.Controller;
 8 import org.springframework.ui.Model;
 9 import org.springframework.web.bind.annotation.RequestMapping;
10 import org.springframework.web.bind.annotation.ResponseBody;
11 import org.springframework.web.bind.annotation.SessionAttributes;
12 
13 import com.alibaba.fastjson.JSONObject;
14 import com.hanqi.dao.SrUserDao;
15 import com.hanqi.model.SrUser;
16 
17 @Controller
18 @SessionAttributes("currentUser")
19 @RequestMapping("sruser")
20 public class SrUserController {
21     
22     @Autowired
23     private SrUserDao srUserDao;
24 
25     @RequestMapping("/login")
26     public String login(SrUser srUser, Model model) {
27         String vname = "login";
28         model.addAttribute("user", srUser);
29         SrUser su = srUserDao.login(srUser);
30         
31         if(su!=null) {
32             vname = "index";
33             model.addAttribute("currentUser", su);
34         }
35         
36         return vname;
37     }
38     
39     @RequestMapping("/register")
40     public String register(SrUser srUser) {
41         srUser.setStatus("1");
42         int a = srUserDao.insertSrUser(srUser);
43         
44         return "regsuccess";
45     }
46     
47     @ResponseBody
48     @RequestMapping("selectAll")
49     public JSONObject selectAll() {
50         JSONObject jo = new JSONObject();
51         List<SrUser> list = srUserDao.selectAll();
52         jo.put("total", list.size());
53         jo.put("rows", list);
54         
55         return jo;
56     }
57     
58 }
package com.hanqi.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hanqi.dao.SrRoleDao;
import com.hanqi.model.SrRole;

@Controller
@RequestMapping("/role")
public class SrRoleController {

    @Autowired
    private SrRoleDao srRoleDao;

    @ResponseBody
    @RequestMapping("/selectAllRoles")
    public List<SrRole> selectAllRoles(String userid) {

        // 查询当前用户拥有的角色
        List<SrRole> list = srRoleDao.selectAllRoles(userid);
        // 查询所有的角色
        List<SrRole> listAll = srRoleDao.selectAll();

        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < listAll.size(); j++) {
                if (listAll.get(j).getId() == list.get(i).getId()) {
                    listAll.get(j).setChecked(true);
                }
            }
        }
        return listAll;
    }
}
 1 package com.hanqi.controller;
 2 
 3 import java.util.ArrayList;
 4 import java.util.List;
 5 
 6 import javax.servlet.http.HttpServletRequest;
 7 
 8 import org.springframework.beans.factory.annotation.Autowired;
 9 import org.springframework.stereotype.Controller;
10 import org.springframework.web.bind.annotation.RequestMapping;
11 import org.springframework.web.bind.annotation.ResponseBody;
12 
13 import com.hanqi.dao.SrMenuDao;
14 import com.hanqi.model.SrMenu;
15 import com.hanqi.model.SrUser;
16 
17 @Controller
18 @RequestMapping("/menu")
19 public class SrMenuController {
20 
21     @Autowired
22     private SrMenuDao srMenuDao;
23     
24     @ResponseBody
25     @RequestMapping("/selectMenus")
26     public List<SrMenu> selectMenus(HttpServletRequest request) {
27         
28         SrUser currentUser = (SrUser)request.getSession().getAttribute("currentUser");
29         
30         List<SrMenu> list = new ArrayList<SrMenu>();
31         if(currentUser!=null) {
32             list = srMenuDao.selectMenus(currentUser);
33         }
34         
35         return list;
36     }
37     
38 }

前台jsp页面:

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <%
 7     String basePath = request.getContextPath();
 8 %>
 9 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
10 <script type="text/javascript" src="<%=basePath %>/js/jquery-3.2.1.min.js"></script>
11 <script type="text/javascript" src="<%=basePath %>/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
12 <link type="text/css" rel="stylesheet" href="<%=basePath %>/jquery-easyui-1.5.1/themes/icon.css"></link>
13 <link type="text/css" rel="stylesheet" href="<%=basePath %>/jquery-easyui-1.5.1/themes/default/easyui.css"></link>
14 <script type="text/javascript" src="<%=basePath %>/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
15 <script type="text/javascript" src="<%=basePath %>/js/index.js"></script>
16 <script type="text/javascript">
17     var __ctx = "<%=basePath %>";
18 </script>
19 <title>Insert title here</title>
20 </head>
21 <body class="easyui-layout">
22     <div data-options="region:‘north‘,title:‘North Title‘,split:true,height:100">
23         <h1>${currentUser.realname }</h1>
24     </div>
25     <div data-options="region:‘west‘,title:‘West‘,split:true,width:150">
26         <ul id="treemenu" class="easyui-tree" 
27             data-options="url:‘<%=basePath %>/menu/selectMenus.do‘,idField:‘id‘,
28             parentField:‘parentid‘,textField:‘menuname‘"></ul>
29     </div>
30     <div data-options="region:‘center‘">
31         <div id="tabs_userrole" class="easyui-tabs" data-options="fit:true">
32         </div>
33     </div>
34 </body>
35 </html>
  1 <%@ page language="java" contentType="text/html; charset=UTF-8"
  2     pageEncoding="UTF-8"%>
  3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4 <html>
  5 <head>
  6 <%
  7     String basePath = request.getContextPath();
  8 %>
  9 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 10 <script type="text/javascript"
 11     src="<%=basePath%>/js/jquery-3.2.1.min.js"></script>
 12 <script type="text/javascript"
 13     src="<%=basePath%>/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
 14 <link type="text/css" rel="stylesheet"
 15     href="<%=basePath%>/jquery-easyui-1.5.1/themes/icon.css"></link>
 16 <link type="text/css" rel="stylesheet"
 17     href="<%=basePath%>/jquery-easyui-1.5.1/themes/default/easyui.css"></link>
 18 <script type="text/javascript"
 19     src="<%=basePath%>/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
 20 <title>Insert title here</title>
 21 </head>
 22 <body>
 23     <table id="userinfo" class="easyui-datagrid"
 24         data-options="toolbar:‘#tools‘,url:‘<%=basePath%>/sruser/selectAll.do‘,fit:true,fitColumns:true,singleSelect:true">
 25         <thead>
 26             <tr>
 27                 <th data-options="field:‘‘,width:100,checkbox:true"></th>
 28                 <th data-options="field:‘id‘,width:100">id</th>
 29                 <th data-options="field:‘username‘,width:100">用户名</th>
 30                 <th data-options="field:‘realname‘,width:100">姓名</th>
 31                 <th data-options="field:‘status‘,width:100">状态</th>
 32                 <th data-options="field:‘mark‘,width:100">备注</th>
 33             </tr>
 34         </thead>
 35     </table>
 36     <div id="tools">
 37         <a class="easyui-linkbutton" iconCls="icon-add" 
 38             onclick="showRoleInfos()">修改角色</a>
 39     </div>
 40     
 41     <div id="dialog_roles" class="easyui-dialog" 
 42         data-options="closed:true,width:200,height:300,title:‘更改角色‘,modal:true">
 43         <ul id="role_tree"></ul>
 44     </div>
 45     
 46     <script type="text/javascript">
 47         function showRoleInfos() {
 48             var data = $("#userinfo").datagrid("getSelected");
 49             $("#role_tree").tree({
 50                 url:"role/selectAllRoles.do",
 51                 checkbox:true,
 52                 idField:"id",
 53                 parentField:"id",
 54                 textField:"rolename",
 55                 queryParams:{
 56                     userid:data.id
 57                 },
 58                 onCheck:function(node, checked) {
 59                     console.log(node);
 60                     console.log(checked);
 61                 }
 62             });
 63             $("#dialog_roles").dialog("open");
 64         }
 65         
 66         
 67         
 68         
 69         
 70         
 71         
 72         //easyui实现自定义simpleData加载
 73         $.fn.tree.defaults.loadFilter = function (data) {
 74             var opt = $(this).data().tree.options;//整个tree的dom对象
 75             var idField, textField, parentField;
 76             if (opt.parentField) {
 77                 idField = opt.idField || id;
 78                 textField = opt.textField || text;
 79                 parentField = opt.parentField;
 80                 var i,l,
 81                 treeData = [],
 82                 tmpMap = [];
 83                 for (i = 0, l = data.length; i < l; i++) {
 84                     tmpMap[data[i][idField]] = data[i];
 85                 }
 86                 for (i = 0, l = data.length; i < l; i++) {
 87                     if (tmpMap[data[i][parentField]] && data[i][idField] != data[i][parentField]) {
 88                         if (!tmpMap[data[i][parentField]][children])
 89                             tmpMap[data[i][parentField]][children] = [];
 90                         data[i][text] = data[i][textField];
 91                         tmpMap[data[i][parentField]][children].push(data[i]);
 92                     } else {
 93                         data[i][text] = data[i][textField];
 94                         treeData.push(data[i]);
 95                     }
 96                 }
 97                 return treeData;
 98             }
 99             return data;
100         };
101     </script>
102     
103     
104     
105 </body>
106 </html>
 1 <%@ page language="java" contentType="text/html; charset=utf-8"
 2     pageEncoding="utf-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 7 <title>Insert title here</title>
 8 </head>
 9 <body>
10     <form action="sruser/login.do" method="post">
11         <table>
12             <tr>
13                 <td>用户名: </td>
14                 <td><input name="username" value="${user.username }" /></td>
15             </tr>
16             <tr>
17                 <td>密码: </td>
18                 <td><input name="password" value="${user.password }" /></td>
19             </tr>
20             <tr>
21                 <td colspan="2"><input type="submit" value="登录" /></td>
22             </tr>
23         </table>
24     </form>
25 </body>
26 </html>
 1 <%@ page language="java" contentType="text/html; charset=utf-8"
 2     pageEncoding="utf-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 7 <title>Insert title here</title>
 8 </head>
 9 <body>
10     <form action="sruser/register.do" method="post">
11         <table>
12             <tr>
13                 <td>用户名: </td>
14                 <td><input name="username" /></td>
15             </tr>
16             <tr>
17                 <td>密码: </td>
18                 <td><input name="password" /></td>
19             </tr>
20             <tr>
21                 <td>确认密码: </td>
22                 <td><input name="password1" /></td>
23             </tr>
24             <tr>
25                 <td>姓名: </td>
26                 <td><input name="realname" /></td>
27             </tr>
28             <tr>
29                 <td colspan="2"><input type="submit" value="注册" /></td>
30             </tr>
31         </table>
32     </form>
33 </body>
34 </html>
 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <%
 7     String basePath = request.getContextPath();
 8 %>
 9 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
10 <title>Insert title here</title>
11 </head>
12 <body>
13 注册成功 !
14 <a href="<%=basePath %>/login.jsp">返回登录</a>
15 </body>
16 </html>

我写的不完全版……补全之后再贴上来

 

JavaWeb之ssm框架整合,用户角色权限管理

标签:tpm   权限管理   doctype   grid   erro   nat   spring   test   href   

原文地址:http://www.cnblogs.com/jiangwz/p/7634882.html

(1)
(5)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!