无意中发现mybatis3.4.5中注入还能这么用:
java代码
params.put("sql", "SELECT * FROM e_eventinfo where stateid=#{stateid} and casetype = #{casetype}");
params.put("accountid", "555");
params.put("casetype", "1");
params.put("stateid", "2");
List<Map<String,Object>> list = testMapper.getResult(params);
mybatis代码:
<select id="getResult" parameterType="map" resultType="map">
${sql}
</select>
控制台打印语句:
Preparing: SELECT * FROM e_eventinfo where stateid=? and casetype = ?
Parameters: 2(String), 1(String)
Total: 1