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
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
"> <!-- 配置数据库连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 向连接池中注入值 -->
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/test"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean>
<!-- 实例化sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 配置hibernate的特性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<!-- 加载hibernate的映射文件 -->
<property name="mappingResources">
<list>
<value>org/guangsoft/pojo/Dept.hbm.xml</value>
<value>org/guangsoft/pojo/User.hbm.xml</value>
<value>org/guangsoft/pojo/Role.hbm.xml</value>
</list>
</property>
</bean> </beans>
transaction.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
"> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 声明事务特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="select*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="*" propagation="REQUIRED" isolation="DEFAULT"/>
</tx:attributes>
</tx:advice>
<!-- 进行aop配置 -->
<aop:config>
<aop:pointcut expression="execution(* org.guangsoft.service.impl.*.*(..))" id="pc"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/>
</aop:config>
</beans>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
">
<import resource="db.xml"/>
<import resource="transaction.xml"/>
<!-- 开启扫描注解 -->
<context:component-scan base-package="org.guangsoft.dao.impl,
org.guangsoft.service.impl,org.guangsoft.action"></context:component-scan>
</beans>