In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article "Mybatis how to pass string parameters, segmentation and traversal" article, the sample code introduced in the article is very detailed, has a certain reference value, interested friends must refer to, for "Mybatis how to pass string parameters, segmentation and traversal", Xiaobian organized the following knowledge points, please follow the pace of Xiaobian step by step slowly understand, then let us enter the theme bar.
How to pass string parameters, split and traverse such as foreground String str = "a,b,c,d,e,f";
This parameter is now required as a parameter of the query statement,
Select * from news where id in (${id})
Using this statement to query normally returns results, but it is bound to create sql injection vulnerabilities.
For example, amend to read:
Select * from news where id in (#{id})
Program error.
Write it correctly as follows id in#{item}Mybatis Pass in the split string as parameter
Requirement: Change a field that specifies some customers
Design: pass two parameters (one field needs to be changed, one customer id string separated by ",")
Problem: SQL statement in mybatis condition error, the reason is that #{clientIds} is passed into sql in the form of string
where id in (#{clientIds}) equals where id in ("1,2,3,4") Error
solve
Method 1: Split the customer id string into lists in the code, list traversal in mybatis
#{item}
Method 2: Split the string in mybatis
#{item}
Method 3, sql injection, changed to where id in (${clientIds})
The above is "Mybatis how to pass string parameters, split and traverse" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.