* ȸ¿ø°¡ÀÔ * ¾ÆÀ̵ð/ºñ¹Ð¹øÈ£ ã±â   ID PW
Last Modified : 2008.07.09

Struts °Ô½ÃÆÇ (¼³Á¤ÆÄÀÏ µû·Î µÎ±â)

Struts ¼³Á¤ ÆÄÀÏÀº struts-config.xml ÆÄÀÏÀÔ´Ï´Ù.
Áö±Ý±îÁö Struts °Ô½ÃÆÇÀÌ /struts µð·ºÅ丮¿¡ ÀÖÀ¸¹Ç·Î
struts-config.xml ÆÄÀÏ¿¡¼­ À̵¿ÇÒ °æ·Î¿¡ ´ëÇÑ ¼³Á¤ Áß path ¼Ó¼ºÀ» path="/struts/view.jsp" ÀÌ¿Í °°ÀÌ Ç¥±âÇß¾î¾ß Çß½À´Ï´Ù.
/strtus µð·ºÅ丮¿¡ ÀÖ´Â Struts °Ô½ÃÆÇ ¸¸À» À§ÇÑ Struts ¼³Á¤ÆÄÀÏÀ» µû·Î µÑ ¼ö ÀÖ½À´Ï´Ù.
¼³Á¤ÆÄÀÏÀ» µû·Î µÎ´Â ¹æ¹ýÀº ¾à¼ÓÀ» ÁöŰ¸é µË´Ï´Ù. /struts µð·ºÅ丮¿¡ ÀÖ´Â ¸ðµâ¿¡ ´ëÇÑ ¼³Á¤ÆÄÀÏÀ̶ó¸é À̸§Àº struts-config-struts.xml À̾î¾ß ÇÕ´Ï´Ù. ÀÌÁ¦ struts-config-struts.xml ¼³Á¤ÆÄÀÏ¿¡¼­´Â path="/struts/view.jsp" ´ë½Å path=/view.jsp" ¿Í °°ÀÌ ¼³Á¤ÇÕ´Ï´Ù.

struts-config-struts.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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-bean
         name="listForm"
         type="com.dadam.form.ListForm"
      />

      <form-bean
         name="gulForm"
         type="com.dadam.form.GulForm"
      />

   </form-beans>

   <!-- ===================== Global Exception Definitions -->

   <global-exceptions>
    
   </global-exceptions>


   <!-- ======================= Global Forward Definitions -->

   <global-forwards>
  
   </global-forwards>


   <!-- ======================= Action Mapping Definitions -->

   <action-mappings>
      <action
         path="/write_form"
         name="gulForm"
         scope="request"
         forward="/write_form.jsp"
      />

      <action
         path="/list"
         type="com.dadam.action.ListAction"
         name="listForm"
         scope="request"
         unknown="false"
         validate="true">
            <forward 
               name="list" 
               path="/list.jsp"
               redirect="false"
            />
      </action>

      <action
         path="/view"
         type="com.dadam.action.ViewAction"
         name="gulForm"
         scope="request"
         unknown="false"
         validate="false">
            <forward 
               name="view" 
               path="/view.jsp"
               redirect="false"
            />
      </action>

      <action
         path="/modify_form"
         type="com.dadam.action.ModifyFormAction"
         name="gulForm"
         scope="request"
         unknown="false"
         validate="false">
            <forward 
               name="modify_form" 
               path="/modify_form.jsp"
               redirect="false"
            />
      </action>

      <action
         path="/modify"
         type="com.dadam.action.ModifyAction"
         name="gulForm"
         scope="request"
         unknown="false"
         validate="false">
            <forward 
               name="success" 
               path="/view.jsp"
               redirect="false"
            />
            <forward 
               name="failure" 
               path="/modify_form.jsp"
               redirect="false"
            />
      </action>

      <action
         path="/delete"
         type="com.dadam.action.DeleteAction"
         name="gulForm"
         scope="request"
         unknown="false"
         validate="false">
      </action>

      <action
         path="/write"
         type="com.dadam.action.WriteAction"
         name="gulForm"
         scope="request"
         unknown="false"
         validate="false">
            <forward 
               name="list" 
               path="/list.jsp"
               redirect="false"
            />
      </action>

   </action-mappings>

</struts-config>

web.xml ÆÄÀÏÀ» ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ÇÕ´Ï´Ù.

web.xml


.. Áß°£ »ý·« ..

<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>
   
   <!--  Ãß°¡ start -->
   <init-param>
      <param-name>config/struts</param-name>
      <param-value>/WEB-INF/struts-config-struts.xml</param-value>
   </init-param>
   <!--  Ãß°¡  end -->
   
   <load-on-startup>2</load-on-startup>
</servlet>

.. Áß°£ »ý·« ..


/struts/index.jsp ÆäÀÌÁö¸¦ ¾Æ·¡ ³»¿ëÀ¸·Î ¸¸µì´Ï´Ù.

/struts/index.jsp

<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<logic:redirect page="/struts/list.do" />

À¥ app ¸¦ ´Ù½Ã ·ÎµåÇϰí
http://localhost:8080/dadam/struts ¸¦ ¹æ¹®ÇÏ¿© Å×½ºÆ®ÇÕ´Ï´Ù.