第六天:小记

  • 网页出现 406 错误
    • 原因及解决方法
      • 查看是否存在Jackson包
      • 请求页面的后缀不能是 .html
  • 解决post乱码问题
@RequestMapping(value = "/httpclient/post", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE + ";charset=utf-8")
  • mybatis 返回主键信息
<insert id="insert" parameterType="com.taotao.pojo.TbContentCategory" >
    <!-- 返回主键 -->
    <selectKey keyProperty="id" resultType="long" order="AFTER">
        SELECT LAST_INSERT_ID()
    </selectKey>>
    insert into tb_content_category (id, parent_id, name,
      status, sort_order, is_parent, 
      created, updated)
    values (#{id,jdbcType=BIGINT}, #{parentId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, 
      #{status,jdbcType=INTEGER}, #{sortOrder,jdbcType=INTEGER}, #{isParent,jdbcType=BIT}, 
      #{created,jdbcType=TIMESTAMP}, #{updated,jdbcType=TIMESTAMP})
</insert>
  • update 返回值问题
    • 使用原生的sql(或者mysql)重复请求update操作的时候,执行两次,update返回影响行数为 0
    • 第三方持久化框架返回来的是被匹配的影响行数,所以返回的始终是1(mybatis)
      • 如果要以返回的行数作为判断结果,需要在mybatis连接数据库的时候加上参数
        jdbc:mysql://${jdbc.host}/${jdbc.db}?useAffectedRows=true
        

猜你喜欢

转载自blog.csdn.net/weixin_38328290/article/details/87902646