错误记录系列一Parameter 'xxxx' not found. Available parameters are [0, 1, param1, param2]] with root cause

以下错误原因是mybatis不识别参数xxxx,在Dao层给接口写别名即可修复

严重 [http-nio-8888-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [SpringMVC] in context with path [/jxssm] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'xxxx' not found. Available parameters are [0, 1, param1, param2]] with root cause
 org.apache.ibatis.binding.BindingException: **Parameter 'xxxx' not found**. Available parameters are [0, 1, param1, param2]
  <select id="findCityAirport" resultMap="CityAirport" parameterType="com.neu.model.CityAirport">
        SELECT city_id ,city_name,airport_name,city_code,city_pinyin,city_abbreviation FROM city_airport WHERE 1=1
        这里使用了cityName,mybatis不识别参数名称,解决方法如下
        <if test="cityName != null and '' != cityName">
            AND city_name LIKE CONCAT('%',#{cityName},'%')
        if>
        <if test="cityCode != null and '' != cityCode">
            AND city_code LIKE CONCAT('%',#{cityCode},'%')
        if>
    select>

解决方法如下:

添加@Param注解
 List findCityAirport(@Param("cityName") String cityName,@Param("cityCode") String cityCode);

你可能感兴趣的:(ssm,错误记录系列)