spring Restful 만들기
페이지 정보
본문
[ @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";
}
}
관련링크
- 이전글windows10 삼바1 버전 공유 하기 20.06.19
- 다음글tensorflow 2.0 Windows 10 install GPU setting 20.04.27
댓글목록
등록된 댓글이 없습니다.