---
title: "Mybatis字符串判断语法"
author: "後知後觉c"
date: "2019-04-10T16:19:37Z"
tags: []
categories: ["编程语言"]
slug: "mybatis"
draft: false
lastmod: "2019-04-19T14:05:26Z"
id: 2439949
url: "https://563432906.iteye.com/blog/2439949"
---

```
<select id="findIdIsNull" resultType="string">
        select XSID from LY_CKBZ_GXJW_XSLSXXB where BJID = #{bjdm} and XH is null
        <if test="type == '1'.toString()">
            order by NLSSORT(XM,'NLS_SORT = SCHINESE_PINYIN_M')
        </if>
        <if test="type == '2'.toString()">
            order by KSH
        </if>
    </select>
```

 

XML的字符串判断语法：

不能写成 &lt;if test="type == '1'"&gt;

正确写法：

&lt;if test='type=="y"'&gt;

&lt;if test="type == 'y'.toString()"&gt; 

 

--摘自[https://blog.csdn.net/xl19961223/article/details/81362696](https://blog.csdn.net/xl19961223/article/details/81362696)