解决方案

福利推荐-办理成功后可加微信领取20红包

No primary or single unique constructor found for interface javax.servlet.http.HttpServletRequest

2024-02-03 21:01:24 michael007js 141

No primary or single unique constructor found for interface javax.servlet.http.HttpServletRequest



 前端发送请求需要根据token获取当前用户信息,但是一直报500,代码如下:

  1. @GetMapping("/getCurrentMerchant")
  2. public Result<Merchant> getCurrentMerchant(HttpServletRequest request) {
  3. String token = request.getHeader("Authorization");
  4. System.out.println(token);
  5. Merchant currentMerchant = (Merchant) redisUtil.get("token_" + token);
  6. if (currentMerchant == null) {
  7. return Result.fail("获取当前用户信息失败!");
  8. }
  9. return Result.success("获取当前用户信息成功!", currentMerchant);
  10. }

此处 HttpServletRequest 导入的包为 import javax.servlet.http.HttpServletRequest;

解决办法:导入包换为:import jakarta.servlet.http.HttpServletRequest;

首页
关于博主
我的博客
搜索