JPetStore 분석 1 - iBatis

- JPetStore 5.0 Example Application
Struts 1.2, beanaction.jar(23,198  bytes)
iBatis 2

- web.xml
  • *.shtml 는 Struts action에서 처리하도록 함.
  • security-constraint 로 jsp파일을 직접 호출하지 못하게 함.
    <security-constraint>
    	<web-resource-collection>
    		<web-resource-name>Restrict access to JSP pages</web-resource-name> 
    		<url-pattern>*.jsp</url-pattern> 
    	</web-resource-collection>
    	<auth-constraint>
    		<description>With no roles defined, no access granted</description> 
    	</auth-constraint>
    </security-constraint>

- /shop/index.shtml
org.apache.struts.beanaction.BeanAction
name=catalogBean
parameter="*"
/catalog/Main.jsp
<%@ include file="../common/IncludeTop.jsp" %>
내용
<%@ include file="../common/IncludeBottom.jsp" %>

- /shop/viewCategory.shtml?categoryId=FISH
org.apache.struts.beanaction.BeanAction
name=catalogBean
catalogBean#viewCategory() //비지니스 메서드 호출
/catalog/Category.jsp
<bean:define id="category" name="catalogBean" property="category"/>
<bean:define id="productList" name="catalogBean" property="productList"/>
<logic:iterate id="product" name="productList">
<tr>
    <td>
        <html:link paramId="productId" paramName="product" paramProperty="productId" page="/shop/viewProduct.shtml">
            <bean:write name="product" property="productId"/>
        </html:link>
    </td>
    <td><bean:write name="product" property="name"/></td>
</tr>
</logic:iterate>
- BeanAction에서는 parameter 설정이 있으면 name의 해당 메서드 호출
parameter 설정이 없으면 path 에서 마지막 경로에 해당하는 메서드 호출
단, parameter가 *이면 어떤 메서드도 호출 안됨.

- 아래와 같이 특정 확장자에 대한 매핑이 가능
<action path="/test.elf" type="org.apache.struts.beanaction.BeanAction"
   name="catalogBean" parameter="*" validate="false">
<forward name="success" path="/t.jsp"/>
</action>