본문 바로가기

나는 엔지니어/스트럿츠

struts.xml --- 액션 나누기

struts.xml 에 액션수가 늘어나면 파일하나에서 관리하기가 힘들어진다.

inclue 태그를 이용해서 이 문제를 해결 할 수가 있다.



 액션이 정의 되어 있는 파일은 config 폴더로 나누었다.














[struts.xml]

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

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">


<struts>

    <include file="config/guestbook.xml"></include>

    <include file="config/HelloAction.xml"></include>

    <include file="config/InputModel.xml"></include>

</struts>


[guestbook.xml]

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

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">


<struts>

    <package name="guestbook" namespace="/" extends="struts-default">

<action name="insert" class="guestbook.InsertAction">

    <result name="success">list.jsp</result>

    <result name="error">list.jsp</result>

</action>

    </package>

</struts>


[HelloAction.xml]

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

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">


<struts>

    <package name="HelloAction" namespace="/" extends="struts-default">

<action name="hello" class="ex01.HelloAction">

<result name="success">HelloResult.jsp</result>

</action>

    </package>

 

</struts>


[InputModel.xml]

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

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">


<struts>

    <package name="InputModel" namespace="/" extends="struts-default">

<action name="inputModel" class="ex02.InputModel">

   <result name="success">output.jsp</result>

</action>

    

    </package>

    

</struts>