Get the App
SLTechnology News&Howtos  ›  Development  › 

How to pass parameters of a single String type in mybatis

Shulou Source: shulou.com Published: 2022-06-02 09:24:19 10月27日 Update

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

Tags: Parameter type single interface mode content method annotation learning practical deeper one-to-one correspondence interest only practical practical simple operation file time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker Shulou Technology MySQL macOS