赞
踩
// 访问方式http://localhost:8082/api/admin/555555
@RequestMapping(value = "/admin/{id}", method = RequestMethod.GET)
public Admin getAccountById(@PathVariable("id") String id) {
return adminService.findAdminById(id);
}
// 访问方式 http://localhost:8082/api/admin/?id=555555
@GetMapping("/admin")
public Admin getAccountById(@RequestParam("id") String id) {
return adminService.findAdminById(id);
}
package net.cyb.demo.controller; import net.cyb.demo.domain.User; import net.cyb.demo.utils.JsonData; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/api/v1/pub/user") public class UserController { /** * 接收from表单 * @param pwd * @param username * @return */ @PostMapping("login") public JsonData login(String pwd,String username){ System.out.println("pwd:"+pwd+"username:"+username); return JsonData.buildSuccess(""); } /** * 接收from表单 * @param user * @return */ @PostMapping("login") public JsonData login(User user){ System.out.println("user"+user.toString()); return JsonData.buildSuccess(""); } /** * 接收JSON数据 * @param user * @return */ @PostMapping("login") public JsonData login(@RequestBody User user){ System.out.println("user"+user.toString()); return JsonData.buildSuccess(""); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。