Map<String,Object> m=new HashMap<String,Object>();
if (name !=null&&name != "")
m.put("name", name);
m.put("start", p.getStart());
m.put("max", p.getPageSize());
List<Employee> list=employeeMapper.getListPage(m);
-------------------->
<select id="getListPage" parameterType="map" resultMap="employeeMap">
<![CDATA[
select * from employee t1 join dept t2 on(t1.deptNo=t2.deptNo)
where
<if test="name != null"> t1.name = #{name}</if>
ORDER BY t1.id desc limit #{start}, #{max}
]]>
</select>
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<if test="name!=null"> t1.name = null</if>
ORDER BY t1.id desc limit' at line 3
### The error may exist in com/employee/dao/EmployeeMapper.xml
### The error may involve com.employee.dao.EmployeeMapper.getListPage-Inline
### The error occurred while setting parameters
### SQL: select * from employee t1 join dept t2 on(t1.deptNo=t2.deptNo) where <if test="name!=null"> t1.name = ?</if> ORDER BY t1.id desc limit ?, ?
### Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<if test="name!=null"> t1.name = null</if>
ORDER BY t1.id desc limit' at line 3
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<if test="name!=null"> t1.name = null</if>
ORDER BY t1.id desc limit' at line 3
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)