示例代码

  1. @RestController
  2. @RequestMapping(value = "/api", method = RequestMethod.GET)
  3. public class ApiController {
  4. @RequestMapping(value = "/get")
  5. @ResponseBody
  6. public HashMap<String, Object> get(@RequestParam String name) {
  7. HashMap<String, Object> map = new HashMap<String, Object>();
  8. map.put("title", "hello world");
  9. map.put("name", name);
  10. return map;
  11. }
  12. @RequestMapping(value = "/getname")
  13. @ResponseBody
  14. public HashMap<String, Object> getname(@RequestParam String name) {
  15. HashMap<String, Object> map = new HashMap<String, Object>();
  16. map.put("title", "hello world");
  17. map.put("name", name);
  18. return map;
  19. }
  20. }