MVC 패턴과 Spring.

Slides:



Advertisements
Similar presentations
Struts 2.0.
Advertisements

Spring 3.0 MVC - Introduction By, Srinivas Reddy.S
TDS Archictecture Dec HTTP Tomcat Server TDS is a data server Datasets motherlode.ucar.edu THREDDS Server NetCDF-Java library Remote Access IDD.
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Beginning Spring MVC Spencer Uresk. Notes This is a training, NOT a presentation Please ask questions This is being recorded
Model-View-Controller ("MVC") This is a architectural design pattern for interactive applications. This design pattern organizes an interactive application.
Struts1 Apache Struts Dr Jim Briggs. Struts2 What is Struts? Struts is an open source framework for building Java web applications Supports MVC/Model.
An Introduction To the Spring M.V.C. Framework Reference From Website By Tom Kochanowicz.
Java Server Pages Russell Beale. What are Java Server Pages? Separates content from presentation Good to use when lots of HTML to be presented to user,
Integrating Servlets and JavaServer Pages Vijayan Sugumaran School of Business Administration Oakland University Parts of this presentation provided by.
Session-01. Layers Struts 2 Framework The struts 2 framework is used to develop MVC-based web application. Struts 1.0 was released in June The.
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
The Spring Framework: A brief introduction to Inversion of Control James Brundege
Intro to Spring CJUG - January What is Spring? “The Spring framework provides central transaction control of various objects.” This means that any.
The Spring Framework A quick overview. The Spring Framework 1. Spring principles: IoC 2. Spring principles: AOP 3. A handful of services 4. A MVC framework.
Spring Framework Benefits…
Struts 2.0 an Overview ( )
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
Michael Rimov Centerline Computers Craig McClanahan Sun Microsystems O’Reilly Open Source Convention July , 2003.
UNIT-V The MVC architecture and Struts Framework.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
SPRING Framework Marcin Sztec.
Spring. Spring Overview Spring Container Concepts Spring and AOP Spring and Data Access Managing Transactions and Resources Remoting and Accessing Enterprise.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
OpusCollege and the use of Spring and iBatis
Jakarta Struts Presented by Object Computing, Inc. (OCI) Written by Greg Elliott
Standalone Java Application vs. Java Web Application
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
CGS – 4854 Summer 2012 Web Site Construction and Management Instructor: Francisco R. Ortega Chapter 3 Part 1.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework,
Introduction to Web Dimitar Nenchev Ivan Nakov
Struts Framework Anna Paščenko. What is Struts?  An open source framework for building Java web applications.
UNIT 30 네트워크 전송 2 로봇 SW 콘텐츠 교육원 조용수.
CSC 2720 Building Web Applications Frameworks for Building Web Applications.
Model View Controller Architecture of Java Web Applications Dr. M V S Peri Sastry, Ph.D.[BITS-Pilani]
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Views Rendering custom views.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
 Obtaining a RequestDispatcher Forwarding requests from servlets to dynamic resources  Forwarding requests from servlets to static resources  Using.
Chapter 11 Invoking Java Code with JSP Scripting Elements.
Markus Hjort Reaktor Innovations Java Web Development T WWW-palvelun HUT
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
MVC 패턴과 Spring.
Singleton Academy, Pune. Course syllabus Singleton Academy Pune – Course Syllabus1.
Chapter 2 Java Struct 2. Content Basic MVC Architecture Struts 2 Overview Struts 2 - Architecture.
.  A reference model developed for an important use case (Air Job) including UI widgets, controllers, services and DAOs.  After full requirement analysis.
JSP / Servet (2) Bayu Priyambadha, S.Kom. MVC (Model View Controller)  Model (data logic)  Java Class (standard class, servlet, JavaBeans, or other.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
Morpheus Server 2.0 정기교육 Version 목 차 Morpheus Server 2.0 SpringFramework API 개발 Morpheus Admin 실 습.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
Enterprise Java v050228MVC1 Model, View, Controller Web Architecture.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
Creative Commons Attribution- ShareAlike 2.5 License Sakai Programmer's Café Sakai Oxford Tetra ELF Workshop Comparative Display Technologies in Sakai.
Structure of a web application
Spring Framework Power to the POJO.
Design Patterns: Model View Controller
An Introduction To the Spring M.V.C. Framework
Unit 6-Chapter 2 Struts.
Intro to Spring CJUG - January 2013.
Java Web Application Framework
CS5220 Advanced Topics in Web Programming Spring – Web MVC
The Model Layer What is Model?
CS320 Web and Internet Programming MVC Architecture
CS5220 Advanced Topics in Web Programming Spring – Web MVC
Presentation transcript:

MVC 패턴과 Spring

MVC 모델 1

MVC 모델 2 - MVC

MVC Controller 사용자 입력 데이터 추출 입력 데이터에 대한 유효성 체크(Java Script를 이용할 경우 JSP(View)에서도 가능) 입력 데이터를 비즈니스 Layer로 전달하기 위한 변환 작업 비즈니스 Layer와 Interface 비즈니스 Layer에서 발생한 에러 처리 비즈니스 Layer에서 반환된 데이터를 View에 전달

MVC Model ?

MVC Model Domain Model =

MVC Domain Model + Model Business Obj = + DAO

MVC 모델 1 B R O W S E 1. Request JSP 2. Response

모델 2 MVC B R O W S E (Controller) Servlet (View) JSP 1. Request 2. Response 3. Request (View) JSP 4. Response

Spring Framework - MVC

Spring Framework - MVC

org.springframework.web.servlet.DispatcherServlet Spring Framework - MVC HttpServletRequest org.springframework.web.servlet.DispatcherServlet Spring MVC Interceptor 1 JDBC ORM Interceptor 2 Interceptor 3 IoC Container Controller Business Object DAO ModelAndView Template - JSP - Velocity Freemarker Page Control - dispatch - redirect Interceptor 3 applicationContext.xml Interceptor 2 action-servlet.xml Interceptor 1 HttpServletResponse

Spring MVC 2 3 1 4 5 6 HandlerMapping 요청 DispatcherServlet Controller ModelAndView 1 4 5 ViewResolver 6 View

Spring MVC 2 3 1 4 5 6 BeanNameUrlHandlerMapping /index.html DispatcherServlet MyUrlFilenameViewController ModelAndView 1 “index” 4 5 InternalResourceViewResolver 6 /WEB-INF/jsp/index.jsp

HelloWorldController Spring MVC 실습 1 HelloWorldController

Spring MVC - Controller

Spring MVC - MultiActionController = DispatchAction of Struts Action of Webwork

Spring MVC - MultiActionController List.do B R O W S E ListAction Insert.do InsertAction Update.do UpdateAction View.do ViewAction Delete.do DeleteAction = 1 : 1 URL : Action

Spring MVC - MultiActionController 단점 URL이 추가될 때마다 Action(Controller)를 추가해야함. Action(Controller)가 추가될 때마다 설정 파일에 Action 정보 추가 하나의 URL이 추가될 때마다 추가되어야 하는 부분이 많아짐으로서 생산성 저하. Action(Controller)의 숫자가 많아질수록 유지보수의 어려움. 너무도 복잡한 설정 파일로 인해 유지보수의 어려움.

Spring MVC - MultiActionController SampleAction List.do B R O W S E Insert.do Update.do View.do Delete.do = N : 1 URL : Action

HelloWorldMultiActionController Spring MVC 실습 2 HelloWorldMultiActionController

Spring MVC - SimpleFormController 기존 방식

Spring MVC - SimpleFormController

Spring MVC 데모 Chapter 6 게시판 예제

Spring MVC - BeanNameUrlHandlerMapping <bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> <bean name="/user/login.do" class="net.javajigi.user.web.LoginFormController"> <property name="validator" ref="beanValidator" /> <property name="formView" value="/decorators/login" /> <property name="successView" value="redirect:/index.html" /> <property name="userService" ref="userService" /> </bean> <bean name="/board/board.do" class="net.javajigi.board.web.BoardController"> <property name="boardService" ref="boardService" /> <property name="methodNameResolver" ref="methodNameResolver" />

Spring MVC - SimpleUrlHandlerMapping <bean id="loginFormController" class="net.javajigi.user.web.LoginFormController"> <property name="validator" ref="beanValidator" /> <property name="formView" value="/decorators/login" /> <property name="successView" value="redirect:/index.html" /> <property name="userService" ref="userService" /> </bean> <bean id="boardController" class="net.javajigi.board.web.BoardController"> <property name="boardService" ref="boardService" /> <property name="methodNameResolver" ref="methodNameResolver" />

Spring MVC - SimpleUrlHandlerMapping <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/user/login.do">loginFormController</prop> <prop key="/board/board.do">boardController</prop> </props> </property> </bean>

Spring MVC - View JSTLView HTML 문서 Excel 문서 ExcelView Model PDFView CSVView CSV 문서

Spring MVC - ViewResolver InternalResource ViewResolver JSP Velocity Velocity ViewResolver Model FreeMarker ViewResolver Freemarker ResourceBundleViewResolver ResourceBundle

java.beans.PropertyEditor

Property Editor <beans> <bean id="builtInSample" class="PropertyEditorBean"> <property name="class"> <value>java.lang.String</value> </property> <property name="file"> <value>c:/test.txt</value> <property name="locale"> <value> en-GB </value> <property name="url"> <value>http://www.springframework.org</value> <property name="properties"> <value> name=foo age=19 </value> <property name="strings"> <value>rob,jan,rod,jurgen,alef</value> <property name="bytes"> <value>Hello World</value> </bean> </beans>

Property Editor import java.io.File; import java.net.URL; import java.util.Locale; import java.util.Properties; public class PropertyEditorBean { private Class cls; private File file; private URL url; private Locale locale; private Properties properties; private String[] strings; private byte[] bytes; }

Convention over Configuration Spring 2.0 Convention over Configuration (CoC)

Spring 2.0 Controller <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" /> HelloWorldController => helloworld.do HelloWorldController.hello => helloworld/hello.do

Model Spring 2.0 x.y.User => user java.util.HashMap => hashMap x.y.User[] => userList 하나 이상의 x.y.User 인스턴스를 가지는 java.util.ArrayList => userList

View Spring 2.0 <bean id="viewNameTranslator" class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> http://localhost:8080/helloworld.do => WEB-INF/jsp/helloworld.jsp http://localhost:8080/helloworld/hello.do => WEB-INF/jsp/helloworld/hello.jsp

HelloWorldMultiActionController를 Spring 2.0 실습 3 HelloWorldMultiActionController를 CoC 기반으로 변경

Spring 설정 파일 관리 수평적 분리

Spring 설정 파일 관리 수직적 분리

Spring 설정 파일 관리 중소규모

Spring 설정 파일 관리 중대규모

참고문서!! RequestDispatcher를 이용할 경우 문제점과 해결방법 : http://wiki.javajigi.net/pages/viewpage.action?pageId=77 Simplify Your Web App Development Using the Spring MVC Framework : http://www.devx.com/Java/Article/22134/1954?pf=true Property Editor Sample : http://www.java2s.com/Code/Java/Spring/PropertyEditorBean.htm