spring Restful 만들기
페이지 정보
작성자 미친새 작성일 20-06-16 22:12 조회 19,907 댓글 0본문
[ @Controller 예제 코드 ]
package com.mang.blog.application.user.controller;
import com.mang.blog.application.user.model.UserVO;
import com.mang.blog.application.user.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@Controller
@RequestMapping("/user")
public class UserController {
@Resource(name = "userService")
private UserService userService;
@RequestMapping(value = "/retrieveUserInfo", method = RequestMethod.POST)
public @ResponseBody UserVO retrieveUserInfo(@RequestBody UserVO userVO){
return userService.retrieveUserInfo(userVO);
}
@RequestMapping(value = "/userInfoView", method = RequestMethod.POST)
public String loginUserView(@RequestBody UserVO userVO, Model model){
model.addAttribute("userInfo", userVO);
return "/user/userInfoView";
}
}
package com.mang.blog.application.user.controller;
import com.mang.blog.application.user.model.UserVO;
import com.mang.blog.application.user.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@Controller
@RequestMapping("/user")
public class UserController {
@Resource(name = "userService")
private UserService userService;
@RequestMapping(value = "/retrieveUserInfo", method = RequestMethod.POST)
public @ResponseBody UserVO retrieveUserInfo(@RequestBody UserVO userVO){
return userService.retrieveUserInfo(userVO);
}
@RequestMapping(value = "/userInfoView", method = RequestMethod.POST)
public String loginUserView(@RequestBody UserVO userVO, Model model){
model.addAttribute("userInfo", userVO);
return "/user/userInfoView";
}
}
관련링크
댓글목록 0
등록된 댓글이 없습니다.