第六天:小記

  • 網頁出現 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
        
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章