2007년 09월 06일
struts2 개발 메모
1 Action 기반의프레임워크
2 성숙하고활기찬개발자와사용자그룹
3 Annotation(주석) 과XML 설정
4 POJO 기반의액션이어서테스트가쉽다
5 Spring, SiteMesh and Tiles 등과의통합
6 OGNL 표현언어integration
7 Themes(주제, 테마) 기반태그라이브러리와Ajax 태크
8 View 계층의다양한옵션(JSP, Freemarker, Velocity and XSLT)
9 Plug-ins to extend and modify framework features
Struts2 – pull-MVC (or MVC2) 프레임워크다. 전통적인MVC 프레임워크랑조금달리
Action은컨트롤러보다모델역할을한다. 비록거기에는약간겹치는부분이있다.
Five Core Components
Action, interceptors, value stack/OGNL, result types and results, view technologies
Value Stack – HttpServletRequest, HttpSession 대신에Value Stack을이용하면
Action Class get, set 설정만으로이용가능하다.
Inteceptors – filter 랑비슷하다.
Struts.properties 파일은web.xml 파일의init-param 속성과struts.xml 파일의constant 를사용해서설정가능하다.
Struts.xml 파일에서
<include file=”xxx-config.xml” />
<include file=”xxx2-config.xml” /> 를사용할때는인클루드하는순서가중요하다.
예를들어xxx2-config.xml에서xxx-config.xml에있는것을사용하려면반드시
xxx-config.xml가먼저인클루드되어야한다.
자동으로 인클루드 되는 struts-default.xml 과 struts-plugin.xml 이 있다.
Struts-default.xml은 Struts2 core 설정, struts-plugin.xml은 particular plug-in 설정
/example/HelloWorldAction.action 같은URL 에서.action은struts-properties 파일에서
Struts.action.extension = action 을바꿔주면된다.
Struts2 는 business Object, data access Object, other resource 를 취득하는 방법으로
Dependency injection, inversion of control 두가지를 제공한다.
Dependency injection – Constructor injection, interface injection and setter injection
Struts2는 setter injection을 사용한다. 적당한 프레임워크로는 Spring 이고 plugin을 통해서 설정
HttpServletRequest 같이 Spring이 관리하지 object는 setter injection과 interface injection을 조합해서 사용한다.
각각의 비지니스 외의 object는 상응하는 interface를 상속한다.
Eclipse 에서 Struts2 톰켓 프로젝트를 생성 했다고 치자
Struts2/WEB-INF/classes/struts.xml
Struts2/WEB-INF/classes/hello/HellowWorld.class
Struts2/hello/HellowWorld.jsp
Struts.xml 설정 파일에서 package 속성에서 name은 이 패키지를 구성하는 유일한
이름이어서 필수 인거 같다. 생략할 경우 에러가 났다.
Namespace 는 URL에서 사용하는 가상 경로인거 같다.
자기 마음 중복만 안되게 바꾸면 되는거 같다. 그 경우 URL도 바꿔야 한다.
Extends 는 자바의 Extends 속성과 비슷한거 같다.
struts2-core-2.0.8.jar 파일 안에 보면 struts-default.xml 파일이 있고 저 안에
struts-default 라는 패키지가 있는데 그걸 상속 하겠다는 뜻일거 같다.
실제 웹사이트 접근 경로는
http://localhost:8080/Struts2/hello/HelloWorld.action
# by | 2007/09/06 14:01 | struts2 | 트랙백 | 덧글(0)





☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]