SSM传智播客杰信项目(一)

【面试】UML、ER、数据库模型的区别
UML 用例图,类图(对应类),序列图,状态图 rose (只有大公司做,ISO要求)
ER 实体和实体的关系(对应domain实体类,配置实体之间的关系)(被模型替代)
模型 (产生数据库表,表之间的关系)(必须)

【面试】PO、VO、BO有什么区别?
PO 持久化对象,跟数据库表对应
VO 视图对象,跟页面对应
BO  业务对象,跟业务逻辑加工对应对象(比较少)
PO、VO、BO人为分类,它们本质没有什么区别,它们都是POJO。

【面试】数据库表是没有boolean,
Mysql tinyint
Oracle number(1)
实际项目中也可以设置为Char(1)

【面试】主键生成策略 代理主键,业务主键
代理主键,跟业务无关,自增,UUID
业务主键,跟业务有密切关系,XXXYYYZZZ,省市县,国家规范,合同号 14JK009
在实际开发中最好使用代理主键。

【面试】CHAR(10)
存储SETS
VARCHAR 4位长度
CHAR10位长度,其他位空格
数据库设计原则
数据库三范式,原则,数据库当中列,表不应该由其他的列加工而得。
数据库三范式有什么好处?表存储的内容比较少,节约表存储空间,数据的唯一出处。
总金额=数量*单价
现今流行的数据库设计原则,反三范式。
随着电脑硬件的发展,原有硬件非常贵,环境对其影响非常大。温度,尘土。价格很便宜。
早期数据设计时强调空间,现在数据库设计强调性能,也就是用户的体验

【面试】生产厂家和货物是什么关系?
一对多 对,样子相同,但货号不同,对杰信来说,它们是不同货物
多对多  错

【面试】外键什么时候创建
开发阶段 测试阶段 试运行阶段 正式上线阶段 维护阶段
否 否 否 是 是
构建复杂SQL时原则
1)从最小的结果集开始查询
2)将它们进行连接,用左连接

在使用hibernate和mybatis一些区别?
应用hibernate,对象映射,对象的关联关系。
应用mybatis,SQL,利用SQL直接查询所需要的内容,提高了获取数据的效率。SQL可以按照用户的业务来挑取所要的字段。
Hibernate当中SQL能否优化,一般情况无法优化SQL,因为hibernat使用HQL,它自动生成SQL语句。Mybatis可以实现手工SQL优化。
Hibernate开发重点,面向对象,来思考,来开发;全自动ORM
Mybatis开发重点,面向SQL,面向过程思考,面向对象的开发;半自动ORM


创建Maven工程,依赖jar

Pom文件依赖
1)spring、springmvc、mybatis 核心的jar包
2)database,log4j 次核心Jar包
3)poi,jfreecharts 第三方jar包
http://search.maven.org
maven的案例,demo,现有项目中去找别人写好的依赖,坐标
创建dao层
创建service层
创建controller层
配置文件sqlMapConfig.xml、beans.xml、springmvc-servlet.xml、web.xml

框架的执行顺序
1)http://localhost/jk/index.jsp
2)在Jsp中利用js跳转
<script type="text/javascript">
   window.location.href = "home.action";//javascript页面跳转
</script>
4) 在homeController中跳转,转入登陆页面
@Controller
public class HomeController {
//系统首页模块
@RequestMapping(value={"/home.action"})//配合web下<url-pattern>/</url-pattern>
public String login(){
return "/index.jsp"; //首页,删除根目录下index.jsp,否则上面url将被拦截进不来
}


5) 在pages/index.jsp中利用按钮提交,fmain.action
@RequestMapping(value="/fmain.action")
public String fmain(){
return "/home/fmain.jsp";
}


2个Dao 1个controller:
public interface BaseDao<T> {
public List<T> findPage(Page page); //分页查询
public List<T> find(Map paraMap);//带条件查询,条件可以为null,既没有条件;返回list对象集合
public T get(Serializable id); //只查询一个,常用于修改
public void insert(T entity); //插入,用实体作为参数
public void update(T entity); //修改,用实体作为参数
public void deleteById(Serializable id);//按id删除,删除一条;支持整数型和字符串类型ID
public void delete(Serializable[] ids);//批量删除;支持整数型和字符串类型ID
}
public abstract class BaseDaoImpl<T> extendsSqlSessionDaoSupport implements BaseDao<T>{
@Autowired
//mybatis-spring 1.0无需此方法;mybatis-spring1.2必须注入。
public void setSqlSessionFactory(SqlSessionFactorysqlSessionFactory){
super.setSqlSessionFactory(sqlSessionFactory);
}
private String ns; //命名空间
public String getNs() {
return ns;
}
public void setNs(String ns) {
this.ns = ns;
}
public List<T> findPage(Page page){
List<T> oList = this.getSqlSession().selectList(ns +".findPage", page);
return oList;
}
public List<T> find(Map map) {
List<T> oList = this.getSqlSession().selectList(ns + ".find",map);
return oList;
}
public T get(Serializable id) {
return this.getSqlSession().selectOne(ns + ".get", id);
}
public void insert(T entity) {
this.getSqlSession().insert(ns + ".insert", entity);
}
public void update(T entity) {
this.getSqlSession().update(ns + ".update", entity);
}
public void deleteById(Serializable id) {
this.getSqlSession().delete(ns + ".deleteById", id);
}
public void delete(Serializable[] ids) {
this.getSqlSession().delete(ns + ".delete", ids);
}
}


工厂举例:
public interface FactoryDao extends BaseDao<Factory> {
}
@Repository
public class FactoryDaoImpl extends BaseDaoImpl<Factory>implements FactoryDao {
//利用默认构造方法初始化命名空间
public FactoryDaoImpl() {
super.setNs("cn.itcast.jk.mapper.FactoryMapper");
}
}
public interface FactoryService {
public List<Factory> findPage(Page page); //分页查询
public List<Factory> find(Map paraMap);//带条件查询,条件可以为null,既没有条件;返回list对象集合
public Factory get(Serializable id); //只查询一个,常用于修改
public void insert(Factory entity); //插入,用实体作为参数
public void update(Factory entity); //修改,用实体作为参数
public void deleteById(Serializable id);//按id删除,删除一条;支持整数型和字符串类型ID
public void delete(Serializable[] ids);//批量删除;支持整数型和字符串类型ID
}
@Service
public class FactoryServiceImpl implements FactoryService{
@Resource
FactoryDao factoryDao;
@Override
public List<cn.itcast.jk.domain.Factory> findPage(Page page){
// TODO Auto-generated method stub
return null;
}
@Override
public List<cn.itcast.jk.domain.Factory> find(Map paraMap){
return factoryDao.find(paraMap);
}
@Override
public cn.itcast.jk.domain.Factory get(Serializable id){
// TODO Auto-generated method stub
return null;
}
@Override
public void insert(cn.itcast.jk.domain.Factory entity) {
entity.setId(UUID.randomUUID().toString());
factoryDao.insert(entity);
}
@Override
public void update(cn.itcast.jk.domain.Factory entity) {
// TODO Auto-generated method stub
}
@Override
public void deleteById(Serializable id) {
// TODO Auto-generated method stub
}
@Override
public void delete(Serializable[] ids) {
// TODO Auto-generated method stub
}
}
@Controller
public class FactoryController extends BaseController {
@Resource
FactoryService factoryService;
//查询
@RequestMapping("/basicinfo/factory/list.action")
public String list(Model model){
List<Factory> dataList = factoryService.find(null);
model.addAttribute("dataList", dataList);
return "/basicinfo/factory/jFactoryList.jsp";
}
//转向新增页面
@RequestMapping("/basicinfo/factory/tocreate.action")
public String tocreate(){
return "/basicinfo/factory/jFactoryCreate.jsp";
}
//新增保存
@RequestMapping("/basicinfo/factory/insert.action")
public String insert(Factory factory){
factoryService.insert(factory);
return "redirect:/basicinfo/factory/list.action";
}
}


配置文件:
beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-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">
<!-- 1.扫描包service,dao -->
<context:component-scanbase-package="cn.itcast.jk.service,cn.itcast.jk.dao"/>
<!-- 2.数据库链接jdbc.properties文件 -->
<context:property-placeholderlocation="classpath:jdbc.properties"/>
<!-- 3.数据源DataSource -->
<bean id="dataSource"class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass"value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="maxPoolSize"value="${c3p0.pool.maxPoolSize}"/>
<property name="minPoolSize"value="${c3p0.pool.minPoolSize}"/>
<property name="initialPoolSize"value="${c3p0.pool.initialPoolSize}"/>
<property name="acquireIncrement"value="${c3p0.pool.acquireIncrement}"/>
</bean>
<!-- 4.Session工厂 SqlSessionFactory -->
<bean id="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- 跟mybatis进行整合 -->
<property name="configLocation"value="classpath:sqlMapConfig.xml"/>
<property name="mapperLocations"value="classpath:cn/itcast/jk/mapper/*.xml"/>
</bean>
<!-- 5.事务tx -->
<bean id="txManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:advice id="txAdvice"transaction-manager="txManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="get*" read-only="true"/>
<tx:method name="view*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expres sion="execution(*cn.itcast.jk.service.*.*(..))" id="txPointCut"/>
<aop:advisor advice-ref="txAdvice"pointcut-ref="txPointCut"/>
</aop:config>
</beans>


jdbc.properties:
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/jkdb?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root
c3p0.pool.maxPoolSize=20
c3p0.pool.minPoolSize=5
c3p0.pool.initialPoolSize=3
c3p0.pool.acquireIncrement=2


sqlMapConfig.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
</configuration>


web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"version="3.0">
<!-- spring listener -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- DispatcherServlet springMVC -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
<!-- 编码过滤器,解决中文乱码 -->
<filter>
<filter-name>SpringEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SpringEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>


springmvc-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-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">
<!-- 1.扫描包,controller -->
<context:component-scanbase-package="cn.itcast.jk.controller"/>
<!-- 2.视图解析器,jspViewResolver -->
<bean id="jspViewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages"/>
<property name="suffix" value=""/>
</bean>
</beans>


resources/cn/itcast/jk/mapper/FactoryMapper.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.itcast.jk.mapper.FactoryMapper">
<resultMap type="cn.itcast.jk.domain.Factory"id="factoryRM">
<id property="id" column="FACTORY_ID"/>
<result property="fullName" column="FULL_NAME"/>
<result property="factoryName" column="FACTORY_NAME"/>
<result property="contacts" column="CONTACTS"/>
<result property="phone" column="PHONE"/>
<result property="mobile" column="MOBILE"/>
<result property="fax" column="FAX"/>
<result property="inspector" column="INSPECTOR"/>
<result property="cnote" column="CNOTE"/>
<result property="orderNo" column="ORDER_NO"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createDept" column="CREATE_DEPT"/>
<result property="createTime" column="CREATE_TIME"/>
</resultMap>
<!-- 查询 -->
<select id="find" parameterType="map"resultMap="factoryRM">
select * from FACTORY_C
where 1=1
order by ORDER_NO
</select>
<!-- 新增 -->
<insert id="insert"parameterType="cn.itcast.jk.domain.Factory">
insert into FACTORY_C
(FACTORY_ID,FULL_NAME,FACTORY_NAME,CONTACTS,PHONE,MOBILE,FAX,INSPECTOR,CNOTE,ORDER_NO,CREATE_BY,CREATE_DEPT,CREATE_TIME)
values
(
#{id,jdbcType=VARCHAR},
#{fullName,jdbcType=VARCHAR},
#{factoryName,jdbcType=VARCHAR},
#{contacts,jdbcType=VARCHAR},
#{phone,jdbcType=VARCHAR},
#{mobile,jdbcType=VARCHAR},
#{fax,jdbcType=VARCHAR},
#{inspector,jdbcType=VARCHAR},
#{cnote,jdbcType=VARCHAR},
#{orderNo,jdbcType=INTEGER},
#{createBy,jdbcType=VARCHAR},
#{createDept,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}
)
</insert>
</mapper>


SSM传智播客杰信项目(一)
帧框架frameset
<html>
<head>
<title>陕西杰信商务综合管理平台</title>
</head>
<frameset rows="125,*" name="topFrameset" border="0">
<frame name="top_frame" scrolling="no" target="middleFrameSet" src="title.action">
<frameset cols="202,*" height="100%" name="middle"frameborder="no" border="0" framespacing="0">
<frame name="leftFrame" class="leftFrame" target="main"scrolling="no" src="left.action" />
<frame name="main" class="rightFrame" src="main.action"/>
</frameset>
</frameset>
<noframes>
<body>
   <p>此网页使用了框架,但您的浏览器不支持框架。</p>
</body>
</noframes>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值