ssm 多次post同一接口 mapper里的selectByPrimaryKey 时不时空指针异常?

新手上路,请多包涵

用postman多次短时间post同一个接口(参数不变),前面几下正常。然后间隔报错(空指针),一次报错一次正常这样子。
代码定位
controller里面部分代码,一些不重要就不写了

...
@Autowired
CategoryService category
//
...

...
    
   Category c = CategoryService.get(cid);
   //Categoroy c = CategoryMapper.selectByPrimaryKey(cid);
   productService.fill(c);
...

cid是一直都能获取的 也转过int和Integer试过很多次了。
就是这里的Category c不一定能获取到,我直接用mapper的也是一样问我呢提,
做的事how2j里面的ssm tmall项目,自己尝试做前后端分离。表示很奇怪,查不到问题所在,所以发个问题。
可以下载github帮忙看看

阅读 2.8k
1 个回答
@Controller
@RequestMapping("") //规范一下,要么去掉,要么就是 @RequestMapping("category")
public class CategoryController {

}
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from category
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectByPrimaryKey" parameterType="integer" resultMap="BaseResultMap">
     select  <include refid="Base_Column_List" />   from category where id = #{id}
  </select>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题