> Hello World !!!

     

@syaku

[Struts2+iBATIS]스트럿츠2 + iBatis 셋팅

 

스트럿츠2 설치하기

사이트 : http://struts.apache.org/ 
다운로드 : http://struts.apache.org/download.cgi#struts216 

현재 최신버전은 2.1.6 이니까, strust-2.1.6-lib.zip 를 받습니다.
lib 폴더를 복사해서~ (lib 폴더에는 jar 파일들이 있습니다.)
WEB-INF/classes/ 아래에 저장합니다. 그럼 경로가 /WEB-INF/classes/lib 가 되겠죠~

 

web.xml

WEB-INF 폴더 아래 web.xml 파일을 열어주세요. 아래의 소스를 삽입하고 저장하세요.

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

 

struts.properties

# /WEB-INF/classes/ 아래에 위치합니다.

struts.i18n.reload = true

# 와일드카드 false = 사용
struts.enable.DynamicMethodInvocation = false

# 액션명 / 사용
struts.enable.SlashesInActionNames = false

# 개발자 모드 (서비스할 경우 꼭 false)
struts.devMode = true
struts.configuration.xml.reload = true

# 언어설정
#struts.locale=en_US

struts.continuations.package = org.apache.struts2.showcase
struts.custom.i18n.resources = globalMessages

struts.action.extension = xs

struts.i18n.encoding = UTF-8

struts.url.http.port = 88

struts.serve.static = true
struts.serve.static.browserCache = false
struts.multipart.maxSize = 10000000000
 

struts.xml

# /WEB-INF/classes/ 아래에 위치합니다.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>


</struts>

 

iBATIS 설치하기

사이트 : http://ibatis.apache.org/
다운로드 : http://ibatis.apache.org/javadownloads.cgi

현재 최신버전은 2.3.4 입니다. 다운받으세요.
압축풀고 lib 폴더안에 jar 파일을 스트럿츠2 와 같은 폴더에 넣습니다.

 

SqlMapConfig.properties

# 데이터베이스 정보
data_source=java:comp/env/jdbc/oracle

# 다른방법
driver = oracle.jdbc.driver.OracleDriver
url = jdbc:oracle:thin:@localhost:1521:oracle
username = test
password = test

 

SqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
  <!-- // iBatis 프로퍼티 설정 -->
  <properties resource="SqlMapConfig.properties" />

  <settings
    cacheModelsEnabled="true"
    enhancementEnabled="true"
    lazyLoadingEnabled="true"
    maxRequests="32"
    maxSessions="10"
    maxTransactions="5"
    useStatementNamespaces="false"
  />

  <transactionManager type="JDBC" >
    <!--
    <dataSource type="SIMPLE">
      <property name="JDBC.Driver" value="${driver}"/>
      <property name="JDBC.ConnectionURL" value="${url}"/>
      <property name="JDBC.Username" value="${username}"/>
      <property name="JDBC.Password" value="${password}"/>
    </dataSource>
    -->
      <dataSource type="JNDI">
          <!-- // iBatis 프로퍼티 data_source 정보 -->
          <property name="DataSource" value="${data_source}" />
      </dataSource>
  </transactionManager>
  <!-- // sqlMap 을 정의함 : 위치는 /WEB-INF/classes/ 아래부터 -->
  <sqlMap resource="test.xml"/>
</sqlMapConfig>

 

 

written by Seok Kyun. Choi. 최석균.
http://www.cyworld.com/syaku
http://syaku.tistory.com
http://syaku.springnot.com

 

이 글은 스프링노트에서 작성되었습니다.