'PetStore'에 해당되는 글 4

  1. 2009.06.10 JPetStore 분석 2 - iBatis
  2. 2009.06.10 JPetStore 분석 1 - iBatis
  3. 2009.06.10 JPetStore 설치 - iBatis
  4. 2009.06.09 Oracle SQL Developer - MySQL

JPetStore 분석 2 - iBatis

Product ID가 빠졌다.

catalog/Product.jsp
13번째 라인에서 item#productId 임.

1. item 을 product 로 변경한다.

Item.xml
product#productId 에는 들어가는데 item#productId 에는 들어가지 않는다.

2. 쿼리에 productId 를 추가한다.

iBatis에서 주석은 -- 대신 /* */ 를 사용할 것.

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파일을 직접 호출하지 못하게 함.

- /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 - BeanAction에서는 parameter 설정이 있으면 name의 해당 메서드 호출
parameter 설정이 없으면 path 에서 마지막 경로에 해당하는 메서드 호출
단, parameter가 *이면 어떤 메서드도 호출 안됨.

- 아래와 같이 특정 확장자에 대한 매핑이 가능

JPetStore 설치 - iBatis

- JPetStore-5.0/build/wars/jpetstore.war 로 배포할 수 있다.
또는
- Eclipse에서 구동시키기
  1. Dynamic Web Project 를 생성한다.
  2. Import
        src : JavaSource
        web : WebContent
        lib : WebContent/WEB-INF/lib

- 기본 설정이 hsqldb로 되어 있으므로 추가적인 설정이나 데이터베이스 없이 바로 구동할 수 있다.

- 다른 데이터베이스로 변경하는 경우에는
  1. JPetStore-5.0/src/ddl/ 의 스크립트를 사용하여 테이블을 생성하고 데이터를 입력한다.
  2. WEB-INF/classes/properties/database.properties 를 설정한다.
  3. Item.xml에서 getItem의 쿼리를 수정한다. : itemid 가 명확하지 않아 에러가 발생하므로 v.ITEMID로 변경한다.

Oracle SQL Developer - MySQL

- F5로 실행시키면 데이터베이스가 변경되지 않는다.