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 use Mybatis to receive Integer parameters

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to use Mybatis to receive Integer parameters, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Mybatis receives Integer parameters

Recently, when I was working on a project, there was a problem when using tags to determine paging parameters in mybatis.

LIMIT # {startRow}, # {selectRow}

This code is used to set paging parameters in SQL, and the received parameters are of type Integer.

We all know that to query the first page, startRow needs to be assigned a value of 0, but this code doesn't work. Normally, 0 is neither null nor an empty string

However, when consulting the data, we know that when mybatis receives the Integer parameter, if the parameter value is 0, it will be parsed to an empty string''.

Solution LIMIT # {startRow}, # {selectRow}

1. Only judge that the Integer parameter is not null, not an empty string.

two。 It can be judged that the parameter is not equal to 0 (not applicable in my case)

Mybatis uses the Integer type when the descendant mybatis forms a sql statement

When a value of type int passed in is 0, it is considered an empty string, so as long as you judge it this way

It will be fine:

AND info.pay_status = # {payStatus}

When the value of payStatus is 0, add another payStatus==0 to enter the if.

The above is all the content of the article "how to use Mybatis to receive Integer parameters". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.

Share To

Development

Wechat

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

12
Report