mybatis防sql注入的方法:
在框架底层,JDBC中的PreparedStatement类添加以下代码,例如:
//安全的,预编译了的
Connection conn = getConn();//取得连接
String sql = "select id, username, password, role from user where id=?"; //履行sql前会预编译号该条语句
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, id);
ResultSet rs=pstmt.executeUpdate();
......
本文来源:https://www.yuntue.com/post/60297.html | 云服务器网,转载请注明出处!

微信扫一扫打赏
支付宝扫一扫打赏