使用Postman测试接口

  • HelloController.java
package com.example.demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class HelloController {
   
    @RequestMapping("/hello")
    public String index() {
   
        return "hello world";
    }

    @RequestMapping("/test")
    public Map<String, String> test() {
   
        Map<String, String> map = new HashMap<String, String>();
        map.put("username", "cat");
        map.put("password", "123456");
        return map;
    }
}