异常信息:
There was an unexpected error (type=Internal Server Error, status=500).
nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userId' in 'class java.lang.Integer'
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userId' in 'class java.lang.Integer'
出错代码:
dao: public int selectDiscussPostRows(int userId);
mapper:
<select id="selectDiscussPostRows" resultType="int" parameterType="int"> select count(*) <where> <if test="userId!=0"> and user_id=#{userId} </if> </where> from discuss_post </select>
出错原因:方法只有一个参数,并且在sql使用了<if> ,需要在参数前添加@Parm
修正代码:
public int selectDiscussPostRows(@Param("userId") int userId);