Mybatis的mapper.xml文件也是要加文件头的

从来好事天生俭,自古瓜儿苦后甜。这篇文章主要讲述Mybatis的mapper.xml文件也是要加文件头的相关的知识,希望能为你提供帮助。
< ?xml version="1.0" encoding="UTF-8" ?>
< !DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
< !-- 写Sql语句-->
< mapper namespace="com.itheima.mybatis.mapper.UserMapper">
< !-- 通过ID查询一个用户 -->
< select id="findUserById" parameterType="Integer" resultType="User">
select * from user where id = #{v}
< /select>

< !-- //根据用户名称模糊查询用户列表
#{}select * from user where id = ?占位符? ==‘五‘
${}select * from user where username like ‘%五%‘字符串拼接

-->
< select id="findUserByUsername" parameterType="String" resultType="com.itheima.mybatis.pojo.User">
select * from user where username like "%"#{haha}"%"
< /select>

< !-- 添加用户 -->
< insert id="insertUser" parameterType="com.itheima.mybatis.pojo.User">
< selectKey keyProperty="id" resultType="Integer" order="AFTER">
select LAST_INSERT_ID()
< /selectKey>
insert into user (username,birthday,address,sex)
values (#{username},#{birthday},#{address},#{sex})
< /insert>

< !-- 更新 -->
< update id="updateUserById" parameterType="com.itheima.mybatis.pojo.User">
update user
set username = #{username},sex = #{sex},birthday = #{birthday},address = #{address}
where id = #{id}
< /update>

< !-- 删除 -->
< delete id="deleteUserById" parameterType="Integer">
delete from user
where id = #{vvvvv}
< /delete>
【Mybatis的mapper.xml文件也是要加文件头的】
< /mapper>










































    推荐阅读