Mybatis用法

<!-- include 引用字段 -->

<sql id="Base_Column_List">
D_RECID, D_USER_NAME, D_NAME, D_TYPE, ...
</sql>

<select id="select" resultMap="BaseResultMap" parameterType="java.util.Map">
select
<include refid="Base_Column_List"/>
from T_PRINT_LAYOUT

</select>

<!-- where标签相当 于where关键字,可以自动去除第一个and -->
<where>
<include refid="get_where"></include>
</where>

<!-- include 引用其他sql段 -->
<sql id="get_where">
</sql>

<!-- CONCAT函数添加前缀后缀,substring_index函数截取'.'前面的内容 -->

select CONCAT(CONCAT('/files',floderpath,'app/'),substring_index(dosname,'.',1),'.jpg') filePath from t

 <!-- foreach用法 需要注意Controller里面的参数2必须为String[] param2 也可以采用arg1 -->

<if test="param2 != null and param2 != ''">
<foreach collection="param2" open=" AND catname IN ( " close=")" item="param2" separator=",">
#{param2}
</foreach>
</if>

原文地址:https://www.cnblogs.com/liw66/p/10413788.html