코딩이 쉬워진다!/02. spring

spring 3일차

javajin 2018. 1. 19. 10:31
728x90
반응형
SMALL
spring16. spring MVC
- 스프링 프레임웤은 MVC말고 다른 여러가지 프로젝트들도 존재하나
  웹에서 개발할때 가장 많이 사용하는 방식인 MVC pattern으로 구축된
  하나의 뼈대라고 보면 된다.
- JSP/Servlet에서 MVC Model 2에 적용된 내용을 좀 더 편리하고 빠르게
  개발 할 수 있도록 정의 해 놓은 것이라고 할 수 있다. 
- 하여, 설정을 하는 방법과 DispatchServlet이 동작하는 방식을 이해하는 
  것이 매우 중요하다.

spring17. spring MVC 동작원리












spring18. spring MVC에 이미지 적용하기
- webapp 밑에 있는 resources 밑에 파일을 넣고, 
  url은 <%=ctx%>/resources/test.jpg 적용을 해야한다.
- webapp/resources/test.jpg 
   -> /resources/ 
     -> <a href="<%=ctx%>/resources/test.jpg"></a>
- webapp/myResources/test.jpg가 있을경우에 적용하는 방법
   -> /myResources/
     -> <img src="<%=ctx%>/resources/test.jpg">
 -> servlet-context.xml 수정 
<resources mapping="/resources/**" location="/resources/" />
[수정]<resources mapping="/myResources/**" location="/myResources/" /> 



spring19. spring 컨트롤러 생성, RequestMapping
1.@Controller : 내가 사용하려고 하는 클래스에 이 어노테이션을 붙인다.
2.@RequestMapping() : url을 매핑하기 위해 사용하는 어노테이션이다.
3.요청 처리를 위한 메소드 구현
4.뷰를 리턴
- 메소드의 리턴타입를 String으로 줄경우에는 
  폴더 + 파일명 return "page/view01";
  파일명        return "view03";



spring20. Model, ModelAndView
- Model        : 데이터를 담아서 처리하는 객체
- ModelAndView : 데이터와 view처리하는 객체
- View         : 화면을 처리하는 객체

spring21. @RequestMappping 처리
1) Controller 를 만든다.
2) Controller 아래에 @RequestMapping()을 선언한다
3) 메소드에 다시 @RequestMappling()을 적용하여 구현한다. =
@Controller
@RequestMapping("/")
public class NZController {
@RequestMapping("/view04")
public String view04(Model model) {
model.addAttribute("view04","화면테스트04");
return "page/view04";
}
}

spring22. HttpServletRequest,  @RequestParam처리, 객체로 넘기기
- HttpServletRequest : 사용해서 데이터 처리하기
-  @RequestParam : ( @RequestParam("id") String id )
- Member : Member객체에 값을 다 담아서 던지는 방법
  id, passwd, name, age


728x90
반응형
LIST

'코딩이 쉬워진다! > 02. spring' 카테고리의 다른 글

spring 6일차  (2) 2018.01.23
spring 5일차  (2) 2018.01.22
spring 4일차  (2) 2018.01.19
spring 2일차  (0) 2018.01.17
spring 1일차  (0) 2018.01.17