裸泳的康只
2022-06-27 22:47
采纳率: 0%
浏览 33

SSM查询不到数据,也不会报错,返回值为null,如何解决?

SSM查询不到数据,也不会报错,返回值为null


```xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--namespace=绑定一个对应的Dao/Mapper接口-->
<mapper namespace="com.luo.dao.GoodsMapper">
<!--增-->
    <insert id="addGoods" parameterType="com.luo.pojo.Goods">
        insert into ssmexercise.goods (id,name,price,quantity)
        values (#{id},#{name},#{price},#{quantity});
    </insert>
<!--删-->
    <delete id="deleteGoods" parameterType="com.luo.pojo.Goods">
        delete from ssmexercise.goods where id=(#{id});
    </delete>
<!--    改-->
    <update id="updateGoods" parameterType="com.luo.pojo.Goods">
        update ssmexercise.goods
        set name=#{name},price=#{price},quantity=#{quantity}
        where id=#{id};
    </update>
    <!--    id查询-->
    <select id="queryGoodsById" parameterType="Map" resultType="com.luo.pojo.Goods">
        select * from ssmexercise.goods where id=#{id};
    </select>
    <!--    全部查询-->
    <select id="queryAllGoods" parameterType="java.lang.Integer" resultType="com.luo.pojo.Goods" >
        select * from ssmexercise.goods;
    </select>
</mapper>

```

```

img

检查数据库字段名
数据库能查出数据

2条回答 默认 最新

相关推荐 更多相似问题