No primary or single unique constructor found for interface javax.servlet.http.HttpServletRequest
前端发送请求需要根据token获取当前用户信息,但是一直报500,代码如下:
@GetMapping("/getCurrentMerchant")
public Result<Merchant> getCurrentMerchant(HttpServletRequest request) {
String token = request.getHeader("Authorization");
System.out.println(token);
Merchant currentMerchant = (Merchant) redisUtil.get("token_" + token);
if (currentMerchant == null) {
return Result.fail("获取当前用户信息失败!");
return Result.success("获取当前用户信息成功!", currentMerchant);
此处 HttpServletRequest 导入的包为 import javax.servlet.http.HttpServletRequest;
解决办法:导入包换为:import jakarta.servlet.http.HttpServletRequest;