mybatis 中,用${}怎么写入动态标签
sMap.put("userLoginname",userName);Stringsql="select*fromsys_user_extwhere1=1anduser_...
sMap.put("userLoginname", userName);
String sql = " select * from sys_user_ext where 1 = 1 and user_name = #{userLoginname} ";
sMap.put("infomap",sql);
这样可以
但是加了动态标签就不行了
String sql = " select * from sys_user_ext <where> 1 = 1 and user_name = #{userLoginname} </where>";
如果这里查询条件需要动态判断
xml里面配置
<select id="list" parameterType="map" resultMap="SysUserExtMap" >
${infomap}
</select> 展开
String sql = " select * from sys_user_ext where 1 = 1 and user_name = #{userLoginname} ";
sMap.put("infomap",sql);
这样可以
但是加了动态标签就不行了
String sql = " select * from sys_user_ext <where> 1 = 1 and user_name = #{userLoginname} </where>";
如果这里查询条件需要动态判断
xml里面配置
<select id="list" parameterType="map" resultMap="SysUserExtMap" >
${infomap}
</select> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询