发表于: 2018-03-09 22:49:27
2 476
今日完成
1.今天周会
(1)对mybatis的回顾;
(2)spring的回顾;
(3)单例模式;
(3)数据库设计三大范式;
a.第一范式(确保每列保持原子性)
第一范式是最基本的范式。如果数据库表中的所有字段值都是不可分解的原子值,就说明该数据库表满足了第一范式。
b.第二范式(确保表中的每列都和主键相关)
第二范式在第一范式的基础之上更进一层。第二范式需要确保数据库表中的每一列都和主键相关,而不能只与主键的某一部分相关(主要针对联合主键而言)。也就是说在一个数据库表中,一个表中只能保存一种数据,不可以把多种数据保存在同一张数据库表中。
c.第三范式(确保每列都和主键列直接相关,而不是间接相关)
第三范式需要确保数据表中的每一列数据都和主键直接相关,而不能间接相关。
以上听师兄讲了之后需要回顾;
2.听了师兄讲解RESTful,但是仍未进行练习;
解决了昨天不能delect的问题,其中未进行代码的改动,原因未明;
增加了insert和update,但是在进行更改数据的操作的时候遇到问题。
对于最开始这里我的思路是,获取URL中的ID的值-执行更新。数据未改变,然后加入下面红色的代码,依然为成功。随后想到可能是因为从URL中获取的数据不应该是只有ID,应该是个对象。这一点明天验证。
@RequestMapping("/update")
public String update(int id) throws Exception {
student.setInt(id);
int a=studentMapper.updateUser(student);
if (a == 1) {
message = "数据修改成功";
}
else {
message = "数据修改失败";
}
return "update";
}
@RequestMapping("/add")
public String insert(Student student2) throws Exception {
studentMapper.insertUser(student2);
return "update";
}
3.在前面对spring和mybatis进行整合中只尝试了一种方法,还有一种可以方式可以少不用mybaits配置文件,网上查找方法后进行尝试,但是未成功。明天继续.暂时认为是下方配置中文件路径未对应上。
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!--加载properties文件,获取数据库连接的一些信息-->
<context:annotation-config/>
<context:component-scan base-package="com"/>
<!--<context:property-placeholder location="db.properties"/>-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/wodeshujuku"/>
<property name="username" value="root"/>
<property name="password" value="w7217459"/>
<!--<property name="maxActive" value="10"/>
<property name="maxIdle" value="5"/>-->
</bean>
<!--使用类构造器实例化bean,class属性表示要使用的类的全限定名 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 加载数据源,使用上面配置好的数据源 -->
<property name="dataSource" ref="dataSource"/>
<!-- 加载mybatis的全局配置文件,放在classpath下的mybatis文件夹中了 -->
<property name="mapperLocations" value="classpath:*.xml"/>
<property name="typeAliasesPackage" value="com.POJO"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.DAO"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</beans>
明天计划
1.解决上面的问题。
2.完成增删改查的基本功能,对上RESTful风格进行尝试。
遇到问题
如上面所述;
收获
经过周会对前面的知识进行了回顾
评论