try {
Claims claims2 = Jwts.parser()
.setSigningKey("itheima")
.parseClaimsJwt("eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoidG9tIiwiaWQiOjEsImV4cCI6MTcwODA3NTEzNn0._K0VHGvo6MNHFsBKFmuIKFyW0bGThi7InfSD0FYqbag")
.getBody();
System.out.println("开始解析");
System.out.println(claims2);
System.out.println("解析成功");
} catch (ExpiredJwtException e) {
System.out.println("JWT已过期");
} catch (UnsupportedJwtException e) {
System.out.println("不支持的JWT");
} catch (MalformedJwtException e) {
System.out.println("JWT格式错误");
} catch (SignatureException e) {
System.out.println("JWT签名错误");
} catch (IllegalArgumentException e) {
System.out.println("JWT字符串为空");
}
执行上述代码输出不支持的JWT
原因parseClaimsJwt修改为parseClaimsJws