설 연수
하하호홓
설 연수
전체 방문자
오늘
어제
  • 분류 전체보기 (231)
    • Back-End (2)
      • Java (20)
      • JSP (13)
      • Spring (18)
      • Kotlin (0)
      • node.js (0)
    • Front-End (68)
      • JavaScript (19)
      • jQuery (39)
      • Angular (4)
      • HTML (5)
    • Dev-Ops (12)
      • Linux, Cloud (5)
      • docker, k8s (5)
      • ElasticSeach (2)
    • Other (33)
      • OOP (3)
      • 알고리즘 (2)
      • DB (12)
      • Git (1)
      • Swift (4)
    • Backup (65)

블로그 메뉴

    공지사항

    인기 글

    태그

    • Redis
    • docker
    • Angular
    • RESTful
    • angular 콜백
    • 크로스도메인
    • INVALID
    • Kafka
    • jquery invalid
    • angular4
    • MYSQL
    • CORS
    • angular2
    • page not found
    • jOOQ
    • flex
    • 패스트캠퍼스
    • mongodb
    • angular callback
    • 404 error

    최근 댓글

    최근 글

    티스토리

    hELLO · Designed By 정상우.
    설 연수

    하하호홓

    Backup

    Struts2_2.3.4 세팅

    2012. 8. 3. 16:07

    본 실습은 Struts2 를 환경을 설정하고 Tomcat 5.5 기반으로 진행
    하도록 하겠습니다.

    1. 준비사항
        - JDK 1.6
        - Tomcat 5.5
        - Struts2 2.3.4
    2. 환경설정 파일의 위치
        - struts.properties: /src... /classes 기준 경로
          (자동으로 인식하며 경로는 출력 루트 하위에 있어야 함)
        - struts.xml: /src... /classes 기준 경로(본 파일은 꼭 해당 위치에)

    3. 환경설정
        가. 프로젝트생성
            - 실제 적용을 하였을 경우에는 일반적은 프로젝트 배포 방식으로 구성 하면 되지만
               실습시에는 동적 다이나믹 방식으로 (이클립스 기반) 생성 하도록 합니다.

        나. 라이브러리 배치
            - struts-2.3.4-all.zip 을 다운로드 하고 압축을 해제 합니다.
            - struts-2.3.4-all.zip\struts-2.3.4\apps\struts2-blank.war 의 압축을 해제하고
               WEB-INF/lib 폴더의 내용을 모두 복사 하여 현 프로젝트내 WEB-INF/lib 로 위치 합니다.

        다. web.xml

            - URL 패턴을 인식 시키고 Struts2 를 연결 합니다.

            <filter>
                <filter-name>struts2</filter-name>
                <filter-class>
                    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
                </filter-class>
            </filter>
            <filter-mapping>
                <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
            </filter-mapping>

        라. struts.xml

            - Action 패턴을 완성 하고 POJO (단순 클래스 방식) 방식을 통해 UI를 연결 합니다.
               ※ Struts2 에서는 ActionForm, Bean이 더욱 간결 하게 운용 됩니다.

            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE struts PUBLIC
                "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                "http://struts.apache.org/dtds/struts-2.3.dtd">
            <struts>
                <constant name="struts.enable.DynamicMethodInvocation" value="false" />
                <constant name="struts.devMode" value="true" />

                <package name="example" extends="struts-default">
                    <action name="index" class="example.IndexAction">
                        <result>/WEB-INF/resource/index.jsp</result>
                    </action>
                </package>
            </struts>

            - package: 패키지 단위로 정보를 관리 할 수 있습니다.
            - package - > namespace: 호출 주소 이전의 부모주소를 관리 합니다.
            - action -> name: 실제 호출되는 마지막 주소를 관리 합니다.
            - constant: Struts2 에서는 struts.properties 와 JDNI (xml) 설정 방식을 지원하며
               JDNI 설정시 사용 됩니다.
            - result: View 의 위치를 지정하며 Struts2 에서는 View를 별 도록 격리 할 수 있습니다.
            - include: 화면상에는 없지만 package를 xml 파일 단위로 관리 할 수 있도록 지원 합니다.

        마. struts.properties

            - Struts2 의 속성을 설정 하며 해당 속성은 xml 기반의 JDNI 와 본 파일을 통하여 공동으로
               관리 또는 단독으로 운영이 가능 합니다.

             예) struts.action.extension=do
                  상위 옵션은 Struts2 는 환경 설정을 하지 않을 경우 각 셋팅 별 기본 옵션으로 자동 동작하며
                  기본 호출 URL 패턴은 *.action 이며 do로 바꾸어 호출 하는 셋팅을 예시로 볼 수 있으며
                  , (컴마) 구분자를 통해서 action, do 동시에 두가지 이상의 URL 패턴을 지원 합니다.

        바. IndexAction.java

            - Struts2 의 Action 은 struts.xml 에서 연결 정의 하며 예시는 아래 와 같습니다.

            package example;

            import com.opensymphony.xwork2.ActionSupport;

            public class IndexAction extends ActionSupport {
                private static final long serialVersionUID = -4039717283252191551L;
                private String temp1;

                public String execute()
                throws Exception {
                    System.out.println("TEST");
                    return SUCCESS;
                }

                public String getTemp1() {
                    return temp1;
                }

                public void setTemp1(String temp1) {
                    this.temp1 = temp1;
                }
            }

            - 빈을 동시에 관리 할 수 있으며 execute 또한 설정을 통하여 바꿀 수 있습니다.

        사. index.jsp

            - View를 별도의 위치또는 기존 위치에서 동시에 관리 할 수 있습니다.

            <%@ page language="java" contentType="text/html; charset=EUC-KR"
                pageEncoding="EUC-KR"%>
            <!DOCTYPE
                html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/html4/loose.dtd">
            <html>
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
            <title>Insert title here</title>
            </head>
            <body>
            Test
            </body>
            </html>

            - tag 는 별도록 추후 매 실습시 마다 올리 도록 하겠습니다.

        아. 기타
            - 도메인 호출시
              http://localhost/infotake/manager/login.action

              localhost: 호스트명
              infotake: 컨텍스트명(컨텍스를 /로 지정할 경우는 해당 부분 빠짐)
              manager: package namespace 명
              login: action 호출명
            


    [출처] Tomcat 5.5 + Struts2_2.3.4|작성자 푸소금


    http://blog.naver.com/infotake/80164253603


    저작자표시 (새창열림)

    'Backup' 카테고리의 다른 글

    스트럿츠2 태그(Struts2 Tag) 라이브러리 구조와 종류  (0) 2012.08.17
    struts.xml이란  (0) 2012.08.03
    intro  (0) 2012.06.09
    IT 개발자를 위한 자기 소개서  (2) 2012.05.24
    UI가 뛰어난 모바일 웹 디자인 15선 모음  (0) 2012.05.14
      'Backup' 카테고리의 다른 글
      • 스트럿츠2 태그(Struts2 Tag) 라이브러리 구조와 종류
      • struts.xml이란
      • intro
      • IT 개발자를 위한 자기 소개서
      설 연수
      설 연수

      티스토리툴바