利用postman测试,采取post方式,提交json数据到服务器端接口,应该如下设置:

postman测试提交json数据到数据接口_java


相应服务器端程序:

@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", "2022-06-15");
String token = JwtUtils.getToken(payload);//生成JWT令牌

return Result.ok().put("token", token);
}
}