以下为#与$的使用区别:
$中间的变量就是直接替换成值的 !
#会根据变量的类型来进行替换 !
比如articleTitle的类型是string, 值是"标题"的时候
$articleTitle$ = 标题
#articleTitle# = '标题'
----------------------------------------
方法一:创建bean使用<select id="sql_test" parameterclass="myPramBean" resultclass="myResult">
select *from tablewhere name in
<iterate property="ids" conjunction="," close=")" open="(" />
#ids[]#
</iterate>
</select>
myPramBean
{
private String code;
private List ids;
...
}
另外一种不需要创建bean的方法:
<select id="testtt" parameterClass="java.util.Map">
SELECT * FROM productnav WHERE id IN
<iterateproperty="inParam" open="(" close=")" conjunction=",">
#inParam[]#
</iterate>
</select>
使用$符号的方法:
<deleteid="deleteRPRByQRIDS"parameterClass="java.lang.String">
delete from RECORD_PERSON_RELATION
where QRID in ($qrIDs$)
</delete>
其中,qrIDs的形式为:
对于数据库表里的相应字段为字符型时:'1','2','3'
对于数据库表里的相应字段为整型时:1,2,3
其它类型以此类推。
注意:这里用"$",而不用”#“
PS:这种用法一定有可用之处,不过本人发现这个完全可以被子查询代替。 where xx in(select 1 from table A where A.xx =xxx),当然最好用exsits