利用postman测试,采取post方式,提交json数据到服务器端接口,应该如下设置:
相应服务器端程序:
@RestController
public class IndexController {
@PostMapping(value = "/token")
public Result getToken(HttpServletRequest request, @RequestBody TokenUser user) {
Map<String, String> payload = new HashMap<>();
payload.put("ip", "192.168.10.8");
payload.put("name", "张三");
payload.put("time", "https://files.jxasp.com/image/2022-06-15");
String token = JwtUtils.getToken(payload);//生成JWT令牌
return Result.ok().put("token", token);
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13