19 Hours: Fuzzy query three solutions ways

.1) There are several ways for these fuzzy queries

  1.${}

    1.1 Use the following

 <if test="stuName!=null and stuName!=''">and stuName like '%${stuName}%'</if>

      1.1.1 This safety problems when the method is not recommended

  2. by value, directly transmitted% xxx% # {value} then received

    2.1 Use the following

 student.setStuName("%p%");
<if test="stuName!=null and stuName!=''">and stuName like #{stuName}</if>  

  3.band label to deal

    3.1 Use the following

<bind name="_stuName" value="'%'+stuName+'%'"></bind>
            <if test="stuName!=null and stuName!=''">and stuName like #{_stuName}</if>

    3.1.1 can bind corresponding to a plurality of secondary stations to deal with the values ​​accessed by name name

 

Guess you like

Origin www.cnblogs.com/thisHBZ/p/12461734.html