讲师:宋江
一.项目背景
项目特色
1.该管理平台采用了当前最流行的S2SH进行总体架构,充分利用框架整合后的各种特性,并加入maven进行项目的分模块开发,有效进行项目管理。
2.采用了BRAC认证模型,有效进行用户权限管理,同时加入当前流行的Shiro安全框架,从而使得系统更加安全可靠。
3.结合Sybase引入数据库设计相关理念,及打断设计理论。
4.使用Apache POI实现海量数据导出。
5.采用跳跃查询相关思想,并结合数据搬家的操作手段,从而有效提高了系统性能。
6.利用CodeMachine实现代码自动生成技术,从而解放程序员的部分编码工作。
7.使用amChart+Flash形成各种统计图形,从而为高层提供决策支撑。
8.引入JavaMail邮件机制,并实现Spring与JavaMail整合开发,实现邮件发送中加入附件。
9.加入了Quartz实现的定时任务调度,并结合Spring整合好的Mail,很好的解决了报表向
公司高层的定时发送功能。
10.引入WebService的CXF开发方式,并与Spring结合,从而很好的解决了电子报运问题
二.界面原型法
原型它的目的,它给客户提前看未来的系统长什么样子。客户就能有一个直观的印象。
界面原型法,在实际需求调研阶段用的非常多。和用户谈需求并进行记录,跟web前端页面工程师沟通,让其设计出一套相关的页面原型,再拿过去与用户再次进行沟通,并修改进行记录,再回来进行页面的修改,如果确认,将来的页面就基本不再改动。
目的就是在最短的时间里,得到用户最真实的需求。
三.UML的UseCase图
1.获取需求是专业的
2.usecase就是用例图,它是专门用于描述需求的
3.uml代表统一建模语言
它包含很多图: 用例图,类图,状态图,序列图…….
4.软件:
Rose, pd(powerDesigner 可以画uml图也可以进行数据库设计),Visio
OOP 面向对象编程
OOM 面向对象建模
OOD 面向对象设计
OOA 面向对象分析 (analysis)
工作空间—新增----oom----use case diagram
需求描述:
四. 系统功能模块结构图
系统功能结构图
它的作用?
1.功能模块一目了然
2.便于分工
3.便于进行项目报价
五.系统框架
如果自己搭建框架:
如果使用的别人的框架:
1.首先看jar包
2.画图
3.确定哪些技术需要学习。
搭建maven结构的过程:
1. 创建父工程
引入这个pom.xml,如果没有本地的更新,也要先进行本地仓库的更新
Pom
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>cn.itcast.jk</groupId> <artifactId>jk_parent</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <name>business_parent</name> <description>business_parent</description> <modules> <module>jk_utils</module> <module>jk_domain</module> <module>jk_dao</module> <module>jk_exception</module> <module>jk_service</module> <module>jk_web</module> </modules> <properties> <shiro.version>1.2.3</shiro.version> <hibernate.version>5.0.7.Final</hibernate.version> <spring.version>4.2.4.RELEASE</spring.version> <slf4j.version>1.6.6</slf4j.version> <c3p0.version>0.9.1.2</c3p0.version> <log4j.version>1.2.12</log4j.version> <struts2.version>2.3.24</struts2.version> <cxf.version>3.0.1</cxf.version> </properties> <dependencies> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.4</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.1.37</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.9.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.2.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-all</artifactId> <version>1.2.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.8</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>4.2.4.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.2.4.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.2.4.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.2.4.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>4.2.4.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>4.2.4.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.2.4.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.3.24</version> <scope>compile</scope> <exclusions> <exclusion> <artifactId>javassist</artifactId> <groupId>javassist</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>2.3.24</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-json-plugin</artifactId> <version>2.3.24</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-convention-plugin</artifactId> <version>2.3.24</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.0.7.Final</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>5.0.7.Final</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.2.1.Final</version> <scope>compile</scope> </dependency> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1.2</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>3.0.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>3.0.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.12</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.6</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.6</version> <scope>compile</scope> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.4</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.codehaus.xfire</groupId> <artifactId>xfire-core</artifactId> <version>1.2.6</version> <scope>compile</scope> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.11</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.11</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>3.11</version> <scope>compile</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc14</artifactId> <version>10.2.0.4.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> <version>2.6.6</version> <scope>compile</scope> </dependency> </dependencies> <repositories> <repository> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>Central Repository</name> <url>https://repo.maven.apache.org/maven2</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <releases> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>Central Repository</name> <url>https://repo.maven.apache.org/maven2</url> </pluginRepository> </pluginRepositories> <build> <sourceDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\src\main\java</sourceDirectory> <scriptSourceDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\src\main\scripts</scriptSourceDirectory> <testSourceDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\src\test\java</testSourceDirectory> <outputDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\target\classes</outputDirectory> <testOutputDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\target\test-classes</testOutputDirectory> <resources> <resource> <directory>E:\Develop_Index\workplace\mars_1\jk_parent\src\main\resources</directory> </resource> </resources> <testResources> <testResource> <directory>E:\Develop_Index\workplace\mars_1\jk_parent\src\test\resources</directory> </testResource> </testResources> <directory>E:\Develop_Index\workplace\mars_1\jk_parent\target</directory> <finalName>jk_parent</finalName> <pluginManagement> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version> </plugin> <plugin> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> </plugin> <plugin> <artifactId>maven-release-plugin</artifactId> <version>2.3.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> <showWarnings>true</showWarnings> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.5</version> <executions> <execution> <id>default-clean</id> <phase>clean</phase> <goals> <goal>clean</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>default-install</id> <phase>install</phase> <goals> <goal>install</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.7</version> <executions> <execution> <id>default-deploy</id> <phase>deploy</phase> <goals> <goal>deploy</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-site-plugin</artifactId> <version>3.3</version> <executions> <execution> <id>default-site</id> <phase>site</phase> <goals> <goal>site</goal> </goals> <configuration> <outputDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\target\site</outputDirectory> <reportPlugins> <reportPlugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> </reportPlugin> </reportPlugins> </configuration> </execution> <execution> <id>default-deploy</id> <phase>site-deploy</phase> <goals> <goal>deploy</goal> </goals> <configuration> <outputDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\target\site</outputDirectory> <reportPlugins> <reportPlugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> </reportPlugin> </reportPlugins> </configuration> </execution> </executions> <configuration> <outputDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\target\site</outputDirectory> <reportPlugins> <reportPlugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> </reportPlugin> </reportPlugins> </configuration> </plugin> </plugins> </build> <reporting> <outputDirectory>E:\Develop_Index\workplace\mars_1\jk_parent\target\site</outputDirectory> </reporting> </project>
|
2. 创建子模块
BaseDao
public interface BaseDao {
//查询所有,带条件查询 public <T> List<T> find(String hql, Class<T> entityClass, Object[] params); //获取一条记录 public <T> T get(Class<T> entityClass, Serializable id); //分页查询,将数据封装到一个page分页工具类对象 public <T> Page<T> findPage(String hql, Page<T> page, Class<T> entityClass, Object[] params);
//新增和修改保存 public <T> void saveOrUpdate(T entity); //批量新增和修改保存 public <T> void saveOrUpdateAll(Collection<T> entitys);
//单条删除,按id public <T> void deleteById(Class<T> entityClass, Serializable id); //批量删除 public <T> void delete(Class<T> entityClass, Serializable[] ids);
} |
BaseDaoImpl
public class BaseDaoImpl implements BaseDao{ private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public Session getSession() { return sessionFactory.getCurrentSession(); }
//带条件查询 public <T> List<T> find(String hql, Class<T> entityClass, Object[] params) { Query query = this.getSession().createQuery(hql); if(params!=null){ for (int i = 0; i < params.length; i++) { query.setParameter(i, params[i]); } } return (List<T>) query.list(); }
//获取一条,根据主键id public <T> T get(Class<T> entityClass, Serializable id) { return (T) this.getSession().get(entityClass, id); }
//分页查询,查询两次,一次查询总数,一次查询分页记录 public <T> Page<T> findPage(String hql, Page<T> page, Class<T> entityClass, Object[] params){
Query query = this.getSession().createQuery(hql); if(params!=null){ for (int i = 0; i < params.length; i++) { query.setParameter(i, params[i]); } }
//查询一次,获取记录总数 int count = query.list().size(); page.setTotalRecord(count);
//设置分页 query.setFirstResult((page.getPageNo()-1)*page.getPageSize()); //设置开始位置 query.setMaxResults(page.getPageSize()); //设置获取几条 page.setResults((List<T>)query.list());
return page; }
//新增和修改,hibernate根据id是否为null自动判断 public <T> void saveOrUpdate(T entity) { this.getSession().saveOrUpdate(entity); }
//集合保存,这时新增还是修改,就自动判断,调用时是否简洁。适合批量新增和修改时。(Mrecord控件) public <T> void saveOrUpdateAll(Collection<T> entitys){ for(T entity : entitys){ this.saveOrUpdate(entity);//为什么hibernate批量操作时,要用循环一条一条记录去更新? } }
//按主键id删除 public <T> void deleteById(Class<T> entityClass, Serializable id) { this.getSession().delete(get(entityClass, id)); }
//批量删除 public <T> void delete(Class<T> entityClass, Serializable[] ids) { for(Serializable s : ids){ deleteById(entityClass, s); } }
} |
applicationContext-dao.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" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"></property> </bean> <bean id="sqlDao" class="cn.itcast.jk.dao.common.SqlDao"> <property name="jdbcTemplate" ref="jdbcTemplate"></property> </bean> --> <bean id="baseDao" class="cn.itcast.jk.dao.impl.BaseDaoImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> </beans> |
applicationContext-action.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" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="loginAction" class="cn.itcast.jk.action.LoginAction" scope="prototype"></bean> <bean id="homeAction" class="cn.itcast.jk.action.HomeAction" scope="prototype"></bean>
</beans> |
applicationContext.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" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 1.dataSource--> <!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="com.mysql.jdbc.Driver" /> <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/jk1201?characterEncoding=utf8" /> <property name="user" value="root" /> <property name="password" value="root" /> </bean> -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /> <property name="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl" /> <property name="user" value="system" /> <property name="password" value="manager" /> </bean> <!-- 2.sessionFactory--> <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> </bean>
<!--Shiro安全框架产生代理子类的方式:使用cglib方式 <aop:aspectj-autoproxy proxy-target-class="true" />-->
<!-- 3.事务管理器--> <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 4.txAdvice--> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="insert*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="get*" read-only="true"/> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice>
<!-- 5.aop--> <aop:config> <aop:pointcut id="pointcut" expression="execution(* cn.itcast.jk.service.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" /> </aop:config>
<!--组装其它配置文件--> <import resource="classpath*:spring/applicationContext-action.xml"></import> <import resource="classpath*:spring/applicationContext-dao.xml"></import> <import resource="classpath*:spring/applicationContext-service.xml"></import> <!-- <import resource="classpath:spring/applicationContext-shiro.xml"></import> <import resource="classpath:spring/applicationContext-job.xml"></import>--> <!-- <import resource="classpath:spring/applicationContext-activiti.xml"></import> -->
</beans> |
hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory> <property name="dialect"> org.hibernate.dialect.Oracle10gDialect </property>
<property name="show_sql">true</property> <property name="format_sql">false</property> <property name="hbm2ddl.auto">none</property> <!-- 懒加载,配合web.xml中配置的 openSessionInViewFilter --> <property name="hibernate.enable_lazy_load_no_trans">true</property> <!--校验模式 JPA java persistent api--> <property name="javax.persistence.validation.mode">none</property>
<!-- 加载映射文件--> <mapping resource="cn/itcast/jk/domain/Dept.hbm.xml"></mapping>
</session-factory> </hibernate-configuration> |
struts.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts> <constant name="struts.ui.theme" value="simple"/> <constant name="struts.devMode" value="true" /> <constant name="struts.i18n.encoding" value="UTF-8" />
<package name="default" namespace="/" extends="struts-default">
<action name="login" method="login" class="loginAction"> <result name="login">/WEB-INF/pages/sysadmin/login/login.jsp</result> <result name="success">/WEB-INF/pages/home/fmain.jsp</result> </action> <action name="logout" method="logout" class="loginAction"> <result name="logout">/WEB-INF/pages/sysadmin/login/logout.jsp</result> </action>
<action name="homeAction_*" method="{1}" class="homeAction"> <result name="fmain">/WEB-INF/pages/home/fmain.jsp</result> <result name="title">/WEB-INF/pages/home/title.jsp</result> <result name="toleft">/WEB-INF/pages/${moduleName}/left.jsp</result> <result name="tomain">/WEB-INF/pages/${moduleName}/main.jsp</result> </action>
</package>
</struts>
|
BaseAction
//通过RequestAware, SessionAware, ApplicationAware实行接口获得request,session,application对象,action中就可直接调用
public class BaseAction extends ActionSupport implements RequestAware, SessionAware, ApplicationAware{ private static Logger log = Logger.getLogger(BaseAction.class);
private static final long serialVersionUID = 1L;
protected Map<String, Object> request; protected Map<String, Object> session; protected Map<String, Object> application;
public Map<String, Object> getRequest() { return request; }
public Map<String, Object> getSession() { return session; }
public Map<String, Object> getApplication() { return application; }
@Override public void setRequest(Map<String, Object> request) { this.request = request; }
@Override public void setSession(Map<String, Object> session) { this.session = session; }
@Override public void setApplication(Map<String, Object> application) { this.application = application; }
} |
六.面试
1.请写出hibernate中主键生成策略常用6种方式
native,uuid,increment,identity,sequence,assigned
2.Byte/Short/int/char/varchar运行速度及区别
运行速度: Byte/Short/int/char/varchar 由快到慢
Char是一个固定长度,这样可能导致空间浪费,但反应快速比varchar快。
Varchar可以做到空间最省,但会多长度比较的过程,所以很浪费时间。
3.面试
请参考数据库表结构写出PO类及映射文件
PO类:
映射文件
面试:PO类的定义规范