赞
踩
- /**
- * 接收json参数,封装为Map
- * @param servletRequest
- * @return
- * @throws Exception
- */
- @PostMapping("/getParam")
- public R getParam(HttpServletRequest servletRequest) throws Exception {
- Map<String,Object> result = new ObjectMapper().readValue(servletRequest.getInputStream(), Map.class);
- log.info("MapController getParam result:{}", JSON.toJSONString(result));
-
- return R.ok().data(result);
- }
- /**
- * 接收GET请求方式的传参:第一种方式
- *
- * @param username 用户名
- * @param password 密码
- * @return
- */
- @GetMapping("/getParam1/{username}/{password}")
- public R getParam1(@PathVariable String username, @PathVariable String password) {
- log.info("GETController getParam1 param username:{},password:{}", username, password);
- User8043VO user8043VO = new User8043VO(username, password);
-
- return R.ok().data(user8043VO);
- }
- /**
- * 接收GET请求方式的传参:第二种方式
- *
- * @param username 用户名
- * @param password 密码
- * @return
- */
- @GetMapping("/getParam2")
- public R getParam2(@RequestParam("username") String username,
- @RequestParam("password") String password) {
- log.info("GETController getParam2 param username:{},password:{}", username, password);
- User8043VO user8043VO = new User8043VO(username, password);
-
- return R.ok().data(user8043VO);
- }
- /**
- * 接收GET请求方式的传参:第三种方式
- *
- * @param id 编号
- * @param username 用户名
- * @param password 密码
- * @return
- */
- @GetMapping("/getParam3/{id}")
- public R getParam3(@PathVariable Long id,
- @RequestParam("username") String username,
- @RequestParam("password") String password) {
- log.info("GETController getParam3 param id:{},username:{},password:{}", id, username, password);
- User8043VO user8043VO = new User8043VO(id, username, password);
-
- return R.ok().data(user8043VO);
- }
- /**
- * 接收GET请求方式的传参:第四种方式
- * @param request
- * @return
- */
- @GetMapping("/getParam4")
- public R getParam4(HttpServletRequest request) {
- String id = request.getParameter("id");
- String username = request.getParameter("username");
- String password = request.getParameter("password");
- log.info("GETController getParam4 param id:{},username:{},password:{}", id, username, password);
-
- User8043VO user8043VO = new User8043VO(Long.parseLong(id), username, password);
-
- return R.ok().data(user8043VO);
- }
- /**
- * 接收POST请求方式的传参:第一种方式
- *
- * @param username 用户名
- * @param password 密码
- * @return
- */
- @PostMapping("/postParam1/{username}/{password}")
- public R postParam1(@PathVariable String username, @PathVariable String password) {
- log.info("POSTController postParam1 param username:{},password:{}", username, password);
- User8043VO user8043VO = new User8043VO(username, password);
-
- return R.ok().data(user8043VO);
- }
- /**
- * 接收POST请求方式的传参:第二种方式
- *
- * @param username 用户名
- * @param password 密码
- * @return
- */
- @PostMapping("/postParam2")
- public R postParam2(@RequestParam("username") String username,
- @RequestParam("password") String password) {
- log.info("POSTController postParam2 param username:{},password:{}", username, password);
- User8043VO user8043VO = new User8043VO(username, password);
-
- return R.ok().data(user8043VO);
- }
- /**
- * 接收POST请求方式的传参:第三种方式
- *
- * @param id 编号
- * @param username 用户名
- * @param password 密码
- * @return
- */
- @PostMapping("/postParam3/{id}")
- public R postParam3(@PathVariable Long id,
- @RequestParam("username") String username,
- @RequestParam("password") String password) {
- log.info("POSTController postParam3 param id:{}, username:{},password:{}", id, username, password);
- User8043VO user8043VO = new User8043VO(id, username, password);
-
- return R.ok().data(user8043VO);
- }
- /**
- * 接收POST请求方式的传参:第四种方式
- *
- * @param request
- * @return
- */
- @PostMapping("/postParam4")
- public R postParam4(HttpServletRequest request) {
- String id = request.getParameter("id");
- String username = request.getParameter("username");
- String password = request.getParameter("password");
-
- log.info("POSTController postParam4 param id:{}, username:{},password:{}", id, username, password);
-
- User8043VO user8043VO = new User8043VO(Long.parseLong(id), username, password);
-
- return R.ok().data(user8043VO);
- }
- /**
- * 接收POST请求方式的传参:第五种方式
- *
- * @param param
- * @return
- */
- @PostMapping("/postParam5")
- public R postParam5(@RequestBody User8043VO param) {
- log.info("POSTController postParam5 param:{}", JSON.toJSONString(param));
-
- return R.ok().data(param);
- }
- /**
- * 接收POST请求方式的传参:第六种方式
- *
- * @param param
- * @return
- */
- @PostMapping("/postParam6")
- public R postParam6(User8043VO param) {
- log.info("POSTController postParam6 param:{}", param);
-
- return R.ok().data(param);
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。