9월, 2010의 게시물 표시

Annotation 기본 설정

 Struts2에서는 Annotation (Java1.5 부터 추가된 클래스나 메서드 위에 @기호와 함께 기재된 문자열로, 메타데이터 기능이다.) 을 사용하여 struts.xml 파일이 없이 직접 mapping하는 방식을 지원한다. 만약 struts.xml에 수행할 action이 없을 경우에 자체적으로 Annotation을 수행하게 된다.  예를 들어 http://localhost:8989/info/list.action  으로 들어온다면 struts.xml에서 먼저 검사를 한다음 수행할 액션이 없을 경우, web.xml의 init-param으로 이동하여 Annotation을 수행하게 된다.  struts.xml을 사용하지 않는다는것은 struts.xml의 actino mapping의 설정을 사용하지 않는 다는 것이고,(struts.xml 있어도 되고, 없어도 되는 옵션이된다는 뜻!) <struts>    <!-- include files -->    <include file="info.xml"/><!-- 사용하지 못한다. --> </struts>   그렇기 때문에 Annotation을 사용한다는 것을 알려줘한다. 그러기 위해서 web.xml에 반드시 설정해줘야 된다. 그리고 Annotation을 사용하면 무조건 default인 ***.action 만 가지고 들어와야 한다.(properties에 설정한 *.do, *.etc등은 안된다.)  또한, action class의 이름은 list.action을 호출하면 ListAction이 되어야 한다. 즉 list.action => list + action = ListAction 이 되야한다. 이렇게 설정해 주어야만 struts2에서 자동으로 mapping을 해준다. ■ 설정 1. web.xml에서 FilterDispatcher의 파라메터를 설정한다.  <ini...

Struts2 기본 환경 설정 및 구현

이미지
기본 환경 설정. 1. library 파일 추가.   apache 사이트의 struts 에서 다운로드. 여기서는 2.0.14 버전을 사용한다. 공부용으로 사용하기 위해 Full Distribution을 다운로드 한다.  다운로드한 파일에서 struts-2.0.14\apps\ 들어가면 struts2-blank-2.0.14.war 파일이 존재 한다. 이 파일은 예제파일로 이것을 기본으로 작업을 수행 할 수 있도록 제동된 파일이다. 이것을 압출해제 하면 struts2-blank-2.0.14\WEB-INF\lib 안에 들어있는 파일 들을 eclipse에서 생성한 프로젝트의 lib 폴더에 복사해서 사용한다. 2. web.xml 파일 설정  <filter>    <filter-name>struts2</filter-name>    <filter-class>  org.apache.struts2.dispatcher.FilterDispatcher    </filter-class> </filter> <filter-mapping>    <filter-name>struts2</filter-name>    <url-pattern>/*</url-pattern>//여기서는 확장자를 기록할 수 없다. 인터센터로부터 사전에 알려줄 수 있다. </filter-mapping> * filter-name은 위에서 설정한 filter-name과 같아야 한다. url-pattern에는 다른 확장자를 사용할 수 없으면 /*가 default다. 다른 확장자는 struts.properties에서 설정 할 수 있다. 3. struts.properites 파일 생성  메모장을 사용하여 struts.properites 파일을 만들고 eclipse의 na...

Struts2의 작동 원리

이미지
Struts2의 작동 원리  Struts2 Framework Architecture Diagram  1. Client가 HttpServletRequest를 요청하면 FrontController인 FilterDispatcher가 받는다.  2. ActionMapper부터 ActionProxy 등을 거쳐 와서 Config 문서인 struts.xml 문서와 추가로 struts.properties 파일을 요구한다. struts.properties는 있으면 로딩하고 없으면 하지 않는다.(없어도 된다)  3. struts.xml과 strtus.properties문서를  Interceptor가 받아온다. 그리고 Client의 모든 Parameter를 가로챈다.  4. Interceptor 은 3단계로 나누어져 있다. 1단계에서는 Client의 모든 Paramter를 가로챈다. 2단계에서는 렌더링 역할을 수행한다.(언어 설정, 보안 설정 등) 3단계에서는 Action의 setter method 를 찾고, 데이터를 푸시하는 역할을 한다.(ActionForm이 필요없다)  5. Business Logic Controller인 Action에서 setter method 메소드를 받아서 비즈니스로직을 수행한다.  6. getter method를 통해 Result로 전달해주거나 받는다. Result에서 적절한 페이지를 선택한다. 이때 Template를 지정한다.(JSP, JSF, Velocity(확장자 : vm), FreeMarker(확장자 : ftl)) 적정할 Template를 잡아서 다시 Interceptor로 보낸다.(getter를 통해서 객체는 머든 상관없다)  7. 다시 역방향으로 간다. 1단계에서 Result에서 적절한 페이지를 선택할때, 그 페이지를 찾는다. 그리고 그 페이지의 Value Stack( 그림에는 없음 )을 갖고, Value Stack에다가 데이터를 넣주고 그냥 찍기만 하면 된다...

Struts 2 는 무엇인가 ?

이미지
Struts 2 는 무엇인가?  WebWork + Struts 가 합쳐진게 Struts 2 이다. http://struts.apache.org/  WebWork는 View Framework 로서 유명하고, 이를 기반으로 WebWork Framework와 Struts Framework가 합쳐져 Struts 2가 탄생.  Struts 1과 Struts 2는 다르며, 그 이유중 하나는 WebWork의 인터셉터 (Interceptor)라는 개념이 들어가 있다.   인터셉터는 HttpRequest를 중간에서 가로채는 Filter와 비슷한 개념이나, Action 전 후에 다른 처리를 할 수 있다. 인터셉터는 AOP(aspect-oriented programming) 개념으로 생각하면 된다고 한다.  그외에 의존성주입(Dependency Injection)을 지원하고, 다양한 Plugin(JFreeChard, Sitemesh 등), Result 타입을 지원한다. http://thinkingblog.tistory.com/7  생각하는 블로그 bnk  

java class loader 에 대하여

이글은 http://www.artima.com/insidejvm/ed2/jvm4.html  이곳에 있는것을 그냥 알고싶어서 적어본다   the Java virtual machine contains two kinds of class loaders: 자바 가상머신에는 두가지의 클래스 로더가 포함되어 있다 a bootstrap class loader 하나는 부트스트랩 로더 and user-defined class loaders. 또 하나는 유저정의 클래스 로더 The bootstrap class loader is a part of the virtual machine implementation, 부트스트랩 클래스 로더는 가상머신의 구현부분의 일부분이다 and user-defined class loaders 그리고 유저정의 클래스 로더는 are part of the running Java application. 실행되는 자바 프로그램의 일부이다 (즉 Java Application 의 일부에 포함한다고 볼수있다) Classes loaded by different class loaders 클래스 로드는 다른 클래스 로더에 의해 자바 버추얼 머신의 네임스페이스로 분리된공간에 로드된다 are placed into separate name spaces inside the Java virtual machine.   The class loader subsystem involves many other parts of the Java virtual machine and several classes from the java.lang library. For example, user-defined class loaders are regular Java objects whose class descends from java.lang.ClassLoader . The methods of class ClassLoader allo...

Elcipse 3.6 Spring IDE Plug in 설치시 에러 문제

Error Message : Missing requirement: Spring IDE AJDT Integration   Elcipse Help - Install New Software   Add Button - Click   Name : 아무거나 허지만 알아봐야 겠지 .. AJDT Update AspectJ Developemtn Tools Location : http://download.eclipse.org/tools/ajdt/36/update    36 - Eclipse versio Helios   Check install : AspectJ Development Tools (Required)           필수설치   이후에 Spring IDE Option 설치 하면 된다 -- 여기저기 뒤져서 찾아서 적어놓은것