发表于: 2018-03-13 21:30:40

1 538


今日完成

1.学了部分html标签,写了几个页面方便任务二使用;


   


2.复习动态sql语句,写入web项目

  由于在平时更新或插入语句时,并不会输入所有字段,所以为了省掉多个构造函数和sql语句,这里需要使用动态sql语句进行判断.

pdate student_copy set name=#{name},QQ=#{QQ} ,onlineID=#{onlineID},time_of_enrollment=#{time_of_enrollment},
graduate_institutions=#{graduate_institutions},report_link=#{report_link},swear=#{swear},hearfrom=#{hearfrom}
,update_at= unix_timestamp(now()) where ID=#{ID}

改为

update student_copy
<set>
   <if test="name!=null and name!=''">name=#{name},</if>
   <if test="QQ!=null and QQ!=''">QQ=#{QQ},</if>
   <if test="onlineID!=null and onlineID!=''">onlineID=#{onlineID},</if>
   <if test="time_of_enrollment!=null and time_of_enrollment!=''">time_of_enrollment=#{time_of_enrollment},</if>
   <if test="graduate_institutions!=null and graduate_institutions!=''">graduate_institutions=#{graduate_institutions},</if>
   <if test="report_link!=null and report_link!=''">report_link=#{report_link},</if>
   <if test="swear!=null and report_link!=''">swear=#{swear},</if>
   <if test="hearfrom!=null and report_link!=''">hearfrom=#{hearfrom},</if>
   update_at=unix_timestamp(now()),
</set>
<where>
<if test="ID!=null and ID!=''">AND ID=#{ID}</if>
</where>

测试类

@Test
public void updateUser() throws Exception {
StudentMapper studentMapper = (StudentMapper) applicationContext.getBean("userMapper");
   Student student=new Student("我的",23333,"sapm-10",8678L,
   "snsdao","bdiasundka",
           "sndoasl","22",null);
   student.setID(43l);
   int a=studentMapper.updateUser(student);
   System.out.println(a);
}

修改后报错,

Caused by: org.apache.ibatis.type.TypeException: Error setting non null for parameter #10 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (10 > number of parameters, which is 9).(原因参数索引超出范围)

暂未解决,明天填坑;

明天计划

1.将今天写的页面投入使用,加入RESTful风格;

遇到问题

----------

收获

学了部分html,不学了,感觉浪费时间了,学这些现在够用了

复习动态sql语句;




返回列表 返回列表
评论

    分享到