修改前
<insert id="insert" parameterType="com.taotao.pojo.TbContent" >
insert into tb_content (id, category_id, title,
sub_title, title_desc, url,
pic, pic2, created,
updated, content)
values (${id,jdbcType=BIGINT}, ${categoryId,jdbcType=BIGINT}, ${title,jdbcType=VARCHAR},
${subTitle,jdbcType=VARCHAR}, ${titleDesc,jdbcType=VARCHAR}, ${url,jdbcType=VARCHAR},
${pic,jdbcType=VARCHAR}, ${pic2,jdbcType=VARCHAR}, ${created,jdbcType=TIMESTAMP},
${updated,jdbcType=TIMESTAMP},${content,jdbcType=LONGVARCHAR})
</insert>
修改后
<insert id="insert" parameterType="com.taotao.pojo.TbContent" >
insert into tb_content (id, category_id, title,
sub_title, title_desc, url,
pic, pic2, created,
updated, content)
values (#{id,jdbcType=BIGINT}, #{categoryId,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR},
#{subTitle,jdbcType=VARCHAR}, #{titleDesc,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR},
#{pic,jdbcType=VARCHAR}, #{pic2,jdbcType=VARCHAR}, #{created,jdbcType=TIMESTAMP},
#{updated,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR})
</insert>
主要是#{}和${}的区别 如果不懂的可以点击查看Mybatis中#{}和${}传参的区别及#和$的区别小结