'PetStore'에 해당되는 글 4건
- 2009.06.10 JPetStore 분석 2 - iBatis
- 2009.06.10 JPetStore 분석 1 - iBatis
- 2009.06.10 JPetStore 설치 - iBatis
- 2009.06.09 Oracle SQL Developer - MySQL
- JPetStore 분석 2 - iBatis
- 日常茶飯事
- 2009. 6. 10. 23:09
Product ID가 빠졌다.
catalog/Product.jsp
13번째 라인에서 item#productId 임.
1. item 을 product 로 변경한다.
Item.xml
product#productId 에는 들어가는데 item#productId 에는 들어가지 않는다.
2. 쿼리에 productId 를 추가한다.
iBatis에서 주석은 -- 대신 /* */ 를 사용할 것.
catalog/Product.jsp
13번째 라인에서 item#productId 임.
1. item 을 product 로 변경한다.
<div id="Catalog"> <h2><bean:write name="product" property="name"/></h2> <table> <tr><th>Item ID</th> <th>Product ID</th> <th>Description</th> <th>List Price</th> <th> </th></tr> <logic:iterate id="item" name="itemList"> <tr> <td> <html:link paramId="itemId" paramName="item" paramProperty="itemId" page="/shop/viewItem.shtml"> <bean:write name="item" property="itemId"/></html:link></td> <td><bean:write name="item" property="productId"/></td> <td> <bean:write name="item" property="attribute1"/> <bean:write name="item" property="attribute2"/> <bean:write name="item" property="attribute3"/> <bean:write name="item" property="attribute4"/> <bean:write name="item" property="attribute5"/> <bean:write name="product" property="name"/> </td> <td><bean:write name="item" property="listPrice" format="$#,##0.00"/></td> <td><html:link styleClass="Button" paramId="workingItemId" paramName="item" paramProperty="itemId" page="/shop/addItemToCart.shtml"> Add to Cart</html:link></td> </tr> </logic:iterate> <tr><td> <logic:notEqual name="itemList" property="firstPage" value="true"> <a class="Button" href="switchItemListPage.shtml?pageDirection=previous"><< Prev</a> </logic:notEqual> <logic:notEqual name="itemList" property="lastPage" value="true"> <a class="Button" href="switchItemListPage.shtml?pageDirection=next">Next >></a> </logic:notEqual> </td></tr> </table> </div>
Item.xml
product#productId 에는 들어가는데 item#productId 에는 들어가지 않는다.
2. 쿼리에 productId 를 추가한다.
<select id="getItemListByProduct" resultClass="item" parameterClass="string" cacheModel="itemCache"> SELECT ITEMID, LISTPRICE, UNITCOST, SUPPLIER AS supplierId, I.PRODUCTID AS "product.productId", /* I.PRODUCTID, */ NAME AS "product.name", DESCN AS "product.description", CATEGORY AS "product.categoryId", STATUS, ATTR1 AS attribute1, ATTR2 AS attribute2, ATTR3 AS attribute3, ATTR4 AS attribute4, ATTR5 AS attribute5 FROM ITEM I, PRODUCT P WHERE P.PRODUCTID = I.PRODUCTID AND I.PRODUCTID = #value# </select>
iBatis에서 주석은 -- 대신 /* */ 를 사용할 것.
- JPetStore 분석 1 - iBatis
- 日常茶飯事
- 2009. 6. 10. 17:03
- JPetStore 5.0 Example Application
Struts 1.2, beanaction.jar(23,198 bytes)
iBatis 2
- web.xml
- /shop/index.shtml
org.apache.struts.beanaction.BeanAction
name=catalogBean
parameter="*"
/catalog/Main.jsp
- /shop/viewCategory.shtml?categoryId=FISH
org.apache.struts.beanaction.BeanAction
name=catalogBean
catalogBean#viewCategory() //비지니스 메서드 호출
/catalog/Category.jsp
parameter 설정이 없으면 path 에서 마지막 경로에 해당하는 메서드 호출
단, parameter가 *이면 어떤 메서드도 호출 안됨.
- 아래와 같이 특정 확장자에 대한 매핑이 가능
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>
- JPetStore 설치 - iBatis
- 日常茶飯事
- 2009. 6. 10. 00:35
- JPetStore-5.0/build/wars/jpetstore.war 로 배포할 수 있다.
또는
- Eclipse에서 구동시키기
- 기본 설정이 hsqldb로 되어 있으므로 추가적인 설정이나 데이터베이스 없이 바로 구동할 수 있다.
- 다른 데이터베이스로 변경하는 경우에는
또는
- Eclipse에서 구동시키기
- Dynamic Web Project 를 생성한다.
- Import
src : JavaSource
web : WebContent
lib : WebContent/WEB-INF/lib
- 기본 설정이 hsqldb로 되어 있으므로 추가적인 설정이나 데이터베이스 없이 바로 구동할 수 있다.
- 다른 데이터베이스로 변경하는 경우에는
- JPetStore-5.0/src/ddl/ 의 스크립트를 사용하여 테이블을 생성하고 데이터를 입력한다.
- WEB-INF/classes/properties/database.properties 를 설정한다.
- Item.xml에서 getItem의 쿼리를 수정한다. : itemid 가 명확하지 않아 에러가 발생하므로 v.ITEMID로 변경한다.
- Oracle SQL Developer - MySQL
- 日常茶飯事
- 2009. 6. 9. 23:15
- F5로 실행시키면 데이터베이스가 변경되지 않는다.
USE JPETSTORE; --F9으로 실행시킬 것. DROP TABLE IF EXISTS lineitem; --F5로 실행 DROP TABLE IF EXISTS orderstatus;
Recent comment