1. SSH项目
OA项目,办公自动化,将公司的数据,文档,流程实现在系统中的管理。
降低人员交流过程中的成本。提高办公的效率。
2 .系统管理
主要实现系统权限的管理,不同的用户登陆后看到菜单项不一样(菜单级的权限控制)。
2.1 RBAC权限模型
基于角色的访问控制(Role-Based Access Control)
总结:系统的权限管理中,是将相应资源的访问权限赋予角色,再将某个用户添加到某个角色
实体:用户表,角色表,资源表,资源_角色表,用户_角色表。
2.2RBAC的数据库模型
3 .搭建项目环境
3.1建立项目目录结构
3.2加入项目jar包
3.3导入js和css
3.4建立项目的配置文件
db.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans
3 xmlns="http://www.springframework.org/schema/beans"
4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5 xmlns:p="http://www.springframework.org/schema/p"
6 xsi:schemaLocation="
7 http://www.springframework.org/schema/beans
8 http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
9 ">
10
11
12 <!-- 配置数据库连接池 -->
13 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
14 <!-- 向连接池中注入值 -->
15 <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
16 <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/test"></property>
17 <property name="user" value="root"></property>
18 <property name="password" value="root"></property>
19 </bean>
20 <!-- 实例化sessionFactory -->
21 <bean id="sessionFactory"
22 class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
23 <!-- 注入数据库连接池 -->
24 <property name="dataSource" ref="dataSource"></property>
25 <!-- 配置hibernate的特性 -->
26 <property name="hibernateProperties">
27 <props>
28 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
29 <prop key="hibernate.show_sql">true</prop>
30 <prop key="hibernate.format_sql">true</prop>
31 <prop key="hibernate.hbm2ddl.auto">update</prop>
32 </props>
33 </property>
34 <!-- 加载hibernate的映射文件 -->
35 <property name="mappingResources">
36 <list>
37 <value>org/guangsoft/pojo/Dept.hbm.xml</value>
38 <value>org/guangsoft/pojo/User.hbm.xml</value>
39 <value>org/guangsoft/pojo/Role.hbm.xml</value>
40 </list>
41 </property>
42 </bean>
43
44 </beans>
transaction.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans
3 xmlns="http://www.springframework.org/schema/beans"
4 xmlns:tx="http://www.springframework.org/schema/tx"
5 xmlns:aop="http://www.springframework.org/schema/aop"
6 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7 xmlns:p="http://www.springframework.org/schema/p"
8 xsi:schemaLocation="
9 http://www.springframework.org/schema/beans
10 http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
11 http://www.springframework.org/schema/tx
12 http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
13 http://www.springframework.org/schema/aop
14 http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
15 ">
16
17 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
18 <property name="sessionFactory" ref="sessionFactory"></property>
19 </bean>
20 <!-- 声明事务特性 -->
21 <tx:advice id="txAdvice" transaction-manager="transactionManager">
22 <tx:attributes>
23 <tx:method name="add*" propagation="REQUIRED" isolation="DEFAULT"/>
24 <tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT"/>
25 <tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT"/>
26 <tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT"/>
27 <tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT"/>
28 <tx:method name="select*" propagation="REQUIRED" isolation="DEFAULT"/>
29 <tx:method name="*" propagation="REQUIRED" isolation="DEFAULT"/>
30 </tx:attributes>
31 </tx:advice>
32 <!-- 进行aop配置 -->
33 <aop:config>
34 <aop:pointcut expression="execution(* org.guangsoft.service.impl.*.*(..))" id="pc"/>
35 <aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/>
36 </aop:config>
37 </beans>
applicationContext.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans
3 xmlns="http://www.springframework.org/schema/beans"
4 xmlns:context="http://www.springframework.org/schema/context"
5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6 xmlns:p="http://www.springframework.org/schema/p"
7 xsi:schemaLocation="
8 http://www.springframework.org/schema/beans
9 http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
10 http://www.springframework.org/schema/context
11 http://www.springframework.org/schema/context/spring-context-3.1.xsd
12 ">
13 <import resource="db.xml"/>
14 <import resource="transaction.xml"/>
15 <!-- 开启扫描注解 -->
16 <context:component-scan base-package="org.guangsoft.dao.impl,
17 org.guangsoft.service.impl,org.guangsoft.action"></context:component-scan>
18 </beans>