论坛首页 入门技术论坛

ibatis中#和$有什么区别?

浏览 4457 次
该帖已经被评为新手帖
作者 正文
   发表时间:2006-11-20  
#和$有什么区别,即select * from topic where id=#id#和select * from topic where id=$id$有区别吗?

还有我要执行这个语句select * from topic where boardid in (1,2,3),配置文件如下:

这样写会报错:
<select id="getLists" resultMap="topicListResult" parameterClass="topicInfo">
    select * from topic
<dynamic prepend="where">
<isNotNull prepend="and" property="boardid">
boardid in (#boardid#)
</isNotNull>
</dynamic>
</select>

这样写就没事,即用$替换#
<select id="getLists" resultMap="topicListResult" parameterClass="topicInfo">
    select * from topic
<dynamic prepend="where">
<isNotNull prepend="and" property="boardid">
boardid in ($boardid$)
</isNotNull>
</dynamic>
</select>

这是为什么?
   发表时间:2006-11-20  
直观的说
#str# 出来的效果是  'str'
$str$ 出来的效果是  str

另外  ##只能用在特定的几个地方 $$可以用在任何地方  比如 order by $str$

你甚至可以直接写  $str$  把 order by 这个字串放在str里传进来

具体的去看ibatis文档
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics