SupplierController.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.sf.eurekaclientdemo2.controller;
  2. import com.sf.eurekaclientdemo2.dto.User;
  3. import org.springframework.web.bind.annotation.GetMapping;
  4. import org.springframework.web.bind.annotation.PathVariable;
  5. import org.springframework.web.bind.annotation.RequestParam;
  6. import org.springframework.web.bind.annotation.RestController;
  7. @RestController
  8. public class SupplierController {
  9. // http://eureka-client-supplier-demo/clientDemo2
  10. // http://localhost:18092/clientDemo2
  11. // http://localhost:18093/clientDemo2
  12. @GetMapping("/clientDemo2")
  13. public String handler() {
  14. String data = "client demo 2 success";
  15. System.out.println(data);
  16. return data;
  17. }
  18. // http://localhost:18092/testId/1
  19. @GetMapping("/testId/{id}")
  20. public String testId(@PathVariable("id") String id) {
  21. System.out.println("handler testId: " + id);
  22. return "TestId Success";
  23. }
  24. // http://localhost:18092/testParam?param=111
  25. @GetMapping("/testParam")
  26. public String testParam(@RequestParam("param") String param) {
  27. System.out.println("handler testParam: " + param);
  28. return "TestParam Success";
  29. }
  30. // http://localhost:18092/testUser?name=zhangsan&desc=something
  31. // private String name;
  32. // private String desc;
  33. @GetMapping("/testUser")
  34. public String testUser(User user) {
  35. System.out.println("handler testUser: " + user);
  36. return "TestUser Success";
  37. }
  38. }