Skip to content

MyBatis常见面试题总结的#{} 和 ${} 的区别是什么描述不准确 #2216

@yanghuoji

Description

@yanghuoji

MyBatis中,${}可以把硬编码的字符串SQL语句当参数使用拼接到XML里sql语句里执行

比如:
sqlStr1 = "left join tableb b on a.id=b.id";
sqlStr2 = "left join tableb c on a.id=c.id";
select * from tablea a
${sqlStr1}
${sqlStr2}
where 1=1 ......

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions