cityName是String类型
List<String> cityNameList = areaService.queryByTableType(new AreaQO("忻州"));
<select id="queryByTableType" resultType="String" parameterType="AreaQO">
select
city_name
from
<!-- <if test="cityName == 忻州">
area_table
</if>
<if test="cityName != 忻州">
weather_table
</if> 错误-->
<if test="cityName == '忻州'"><!--正确-->
area_table
</if>
<if test="cityName != '忻州'"><!--正确-->
weather_table
</if>
where 1=1
<!--<if test="cityName !=null and cityName == 忻州"> 错误-->
<if test="cityName !=null and cityName == '忻州'"> <!--正确-->
and city_name=#{cityName}
</if>
</select>
版本:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>1.3.2</version>
</dependency>