스트러츠(Struts) 기본 세팅

Posted at 2009. 6. 22. 22:10 | Posted in Framework/Struts
반응형
이클립스에서 스트러츠를 시작하기 위한 아주아주 기본적인 세팅입니다.

이걸 해야 스트러츠를 시작할 수 있죠!! >,.<

- Eclipse Ganymede 3.4.2
- Apache Tomcat 6.0.18
- Apache Struts 1.3.10
- Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
- 텍스트 인코딩 : 글로벌 시대에 맞게 UTF-8




- File → New → Dynamic Web Project




- 스트러츠 라이브러리를 다운로드받습니다.



- WEB-INF/lib 폴더에 다 때려넣습니다.




- web.xml 을 수정합니다. 주석달린 두 부분(?)을 추가합니다.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 id="WebApp_ID" version="2.5">

  <display-name>BaseStruts</display-name>

  <!-- Standard Action Servlet Configuration -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>

  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>


- WEB-INF 폴더에 struts-config.xml 파일을 만듭니다. (web.xml 파일의 init-param 의 경로와 일치해야함!)

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
    <!--  Form Bean Definitions -->
    <form-beans>

    </form-beans>

    <!--  Global Exception Definitions -->
    <global-exceptions>

    </global-exceptions>

    <!-- Global Forward Definitions -->
    <global-forwards>

    </global-forwards>

    <!-- Action Mapping Definitions -->
    <action-mappings>

    </action-mappings>

    <!-- Message Resources Definitions -->
    <!-- Plug Ins Configuration -->

</struts-config>


스트러츠를 사용하기 위한 완전 아무것도 없는 프로젝트를 만들었습니다... 자! 이제 쓰세요 -_-;;




... 뭐 간단한거라도 만들어볼까요?;; 로그인 하는거 만들어봅시다 >,.<

위에서 만들었던 BaseStruts 를 Import 해서 기본 스트러츠를 세팅합시다!


- File → Import : Web → WAR File




- 프로젝트 이름 변경 하시구!




- 소스 줄줄이 작성! (너무 간단한 예제라 다 펼쳐놓기가 부끄럽군요! ㅠ_ㅠ)

뭐.. UML 은 당연히 틀렸겠죠 +_+;

클래스 다이어그램(Class Diagram)


시퀀스 다이어그램(Sequence Diagram) 


struts-config.xml


    <form-beans>
        <form-bean name="JFLogin" type="com.tistory.antop.forms.JFLogin" />
    </form-beans>

    <action-mappings>
        <action path="/JALogin" type="com.tistory.antop.actions.JALogin"
            name="JFLogin" scope="request" validate="true">
            <forward name="result" path="/result.jsp" />
        </action>
    </action-mappings>




실행은 의지를 가진 용자들은 알아서 하실꺼....



2010.01.26 - 한글 파라미터 처리를 위한 플러그인 클래스 추가
반응형

'Framework > Struts' 카테고리의 다른 글

*.jsp 접근 막기  (0) 2009.09.03
Struts 파일 업로드  (2) 2009.05.05
//