Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to pass parameters of a single String type in mybatis

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to pass a single String type parameter in mybatis". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to pass a single String type parameter in mybatis"!

How to pass parameters of a single String type

When using mybatis interface parameter with only one string, if @Param is not specified, mybatis will default parameterType parameter to the parameter type of the interface, and then call the get/set method of parameter a under this type for #{a} parameter in xml, and then report an error.

Using @Param annotation mybatis will assign values one by one and will not cause this error.

The interfaces are as follows:

The xml file is as follows:

The error is as follows:

Change it to the following:

mybatis Error when only one String parameter is passed

When mybatis is passed with only one parameter of type String, the following methods cannot be used

List

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: 286

*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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report