hello, i have a question, why '${item[fieldName]}' can get value?

49 views
Skip to first unread message

东东

unread,
Nov 29, 2023, 7:42:27 AM11/29/23
to mybatis-user

IMG_20231129_180801.jpg
usually, we get item's value by #{item.XXX},why ${item[XX]} can also get right value?

Iwao AVE!

unread,
Nov 30, 2023, 8:17:26 AM11/30/23
to mybati...@googlegroups.com
Hello,

Please do not use images for posting text information (code, messages, etc.).

We know nothing about your application.
Please provide the details about the parameters (type, value, etc.).
Also, explain what exactly happens (e.g. error? unexpected result?).

The best way to explain your problem is to share a small repro project.
Here are some templates and examples.

Regards,
Iwao

On Wed, Nov 29, 2023 at 9:42 PM 东东 <hcx...@gmail.com> wrote:

IMG_20231129_180801.jpg
usually, we get item's value by #{item.XXX},why ${item[XX]} can also get right value?

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/7f481561-58ab-4c29-ab47-442ab35373dbn%40googlegroups.com.

aa

unread,
Nov 30, 2023, 8:46:21 AM11/30/23
to mybati...@googlegroups.com
If you are asking about #{} vs ${} operators, the difference is that when you use #{} you end up with a parametrized query, which is safe against SQL injection attacks Vs when you use ${} you will end up with plain string injection into SQL query, which is prone to SQL injection attacks. You must use the ${} approach only when you have full control over the string you are injecting into your query. 

Reply all
Reply to author
Forward
0 new messages