How to pass parameters of a single String type in mybatis
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