1. pom.xml

 

아래 기존 jackson 1.x 버전은

<dependency>

<groupId>org.codehaus.jackson</groupId>

<artifactId>jackson-mapper-asl</artifactId>

<version>1.9.2</version>

</dependency>

보안이슈가 있으므로 스프링 4.x 부터   jackson 2.x 로 변경해줌.

 

		<dependency>
		       <groupId>com.fasterxml.jackson.core</groupId>
		      <artifactId>jackson-core</artifactId>
		      <version>2.9.10</version>
		</dependency>
		<dependency>
		  <groupId>com.fasterxml.jackson.core</groupId>
		  <artifactId>jackson-databind</artifactId>
		  <version>2.9.10</version>
		</dependency>
		<dependency>
		    <groupId>com.fasterxml.jackson.core</groupId>
		    <artifactId>jackson-annotations</artifactId>
		    <version>2.9.10</version>
		</dependency>

 

 

2. WEB-INF/config/egovframework/springmvc/egov-com-servlet.xml

 

기존 : 

	<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0"/>

	<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="1" 
    p:prefix="/WEB-INF/jsp/" 
    p:suffix=".jsp" 
    p:viewClass="org.springframework.web.servlet.view.JstlView"/>

 

 

변경 : jsonView 추가 및 order 순서 변경

 

    
	<bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
	
		<property name="contentType" value="application/json;charset=UTF-8" />

	</bean>
   
    <bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
		<property name="order" value="1">
	</property></bean>
	

    <!-- 화면처리용 JSP 파일명의  prefix, suffix 처리에 대한 mvc 설정  -->
    <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="2"
	    p:viewClass="org.springframework.web.servlet.view.JstlView"
	    p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/>
    		

 

3. Controller

 

ModelAndView 형태의 메소드 사용

@RequestMapping(value="/test.do", method=RequestMethod.POST)
	public ModelAndView testList(
			@RequestParam(value="test", required=false) final String test,
            @ModelAttribute("TestVO") TestVO testVO, 
			HttpServletRequest request, HttpServletResponse response, ModelMap model) throws Exception {
				
		
				
		//검색 목록
		List<TestVO> result = testService.testList(testVO);
		
		int resultCnt = testService.testListCnt(testVO);
		

		ModelAndView mav = new ModelAndView("jsonView");
		mav.addObject("resultList", result);		//목록리스트
		mav.addObject("resultCnt", resultCnt);		//목록 수
		mav.addObject("testVO", testVO);	//해당 VO

		
		return mav;
		
		
	}

 

블로그 이미지

엘로드넷

댓글을 달아 주세요

1. Tomcat server.xml 에 설정정보 추가



<GlobalNamingResources>


<!-- Oracle -->


<Resource name="jdbc/JNDI_ORACLE" auth="Container" 


                  connectionProperties="SetBigStringTryClob=true" 

                  driverClassName="oracle.jdbc.driver.OracleDriver"


                  maxActive="2" 

 maxIdle="2" 

 maxWait="-1" 

                  type="javax.sql.DataSource" 

                  url="jdbc:oracle:thin:@192.168.0.10:1521:ORCL"


                  username="TEST" password="TEST" />


<!-- MySQL -->


<Resource name="jdbc/JNDI_MYSQL" auth="Container" 


                  driverClassName="com.mysql.jdbc.Driver"


                  maxActive="8" maxIdle="8" maxWait="-1" 

                  type="javax.sql.DataSource" 

                  url="jdbc:mysql://192.168.0.11:3306/TESTDB"


                  username="TEST" password="TEST" />




<GlobalNamingResources>




2. Tomcat context.xml 에 설정정보 추가


<Context>


<!-- Oracle -->

<ResourceLink name="jdbc/JNDI_ORACLE"


                  global="jdbc/JNDI_ORACLE"

                  auth="Container"

                  type="javax.sql.DataSource" />


<!-- MySQL -->

<ResourceLink name="jdbc/JNDI_MYSQL"


                  global="jdbc/JNDI_MYSQL"

                  auth="Container"

                  type="javax.sql.DataSource" />



</Context>




3. context-datasource.xml 설정 변경


파일위치 : /프로젝트명/src/main/resources/egovframework/spring/com/context-datasource.xml



[변경전]



<!--

    <bean id="dataSource-oracle" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

        <property name="driverClassName" value="${Globals.DriverClassName}"/>

        <property name="url" value="${Globals.Url}" />

        <property name="username" value="${Globals.UserName}"/>

        <property name="password" value="${Globals.Password}"/>

        <property name="initialSize" value="0"/>

        <property name="maxActive" value="2"/>

        <property name="maxIdle" value="2"/>

        <property name="minIdle" value="0"/>

        <property name="maxWait" value="-1"/>

    </bean>



    <bean id="dataSource-mysql" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

        <property name="driverClassName" value="${Globals.DriverClassName}"/>

        <property name="url" value="${Globals.Url}" />

        <property name="username" value="${Globals.UserName}"/>

        <property name="password" value="${Globals.Password}"/>

        <property name="initialSize" value="0"/>

        <property name="maxActive" value="2"/>

        <property name="maxIdle" value="2"/>

        <property name="minIdle" value="0"/>

        <property name="maxWait" value="-1"/>

    </bean>

-->



[변경후]


기존 bean 설정을 주석처리하고



<!-- Oracle -->

    <bean id="dataSource-oracle" class="org.springframework.jndi.JndiObjectFactoryBean">


        <property name="jndiName" value="java:comp/env/jdbc/JNDI_ORACLE"/>


    </bean>




<!-- MySQL -->

    <bean id="dataSource-mysql" class="org.springframework.jndi.JndiObjectFactoryBean">


        <property name="jndiName" value="java:comp/env/jdbc/JNDI_MYSQL"/>


    </bean>



끝.

블로그 이미지

엘로드넷

댓글을 달아 주세요

JSP htmlspecialchars

JAVA 2019. 1. 8. 21:53

JSP htmlspecialchars

 

 

StringBuffer sb = new StringBuffer();

for(int i=0; i<content.length(); i++){

char c = content.charAt(i);

  switch (c) {

    case '<' : 

      sb.append("<");

      break;

    case '>' : 

      sb.append(">");

      break;

    case '&' :

      sb.append("&");

      break;

    case '"' :

      sb.append(""");

      break;

    case '\'' :

      sb.append("'");

      break;

    default:

      sb.append(c);

 

}

}



블로그 이미지

엘로드넷

댓글을 달아 주세요

JSP 확장자 구하기

JAVA 2019. 1. 8. 21:53

JSP 확장자 구하기 : 

 

String filePath = "/www/test.jsp";
   int pos = filePath.lastIndexOf( "." );
   String fileExt = filePath.substring( pos + 1 );
   out.println("파일확장자는: "+fileExt);



블로그 이미지

엘로드넷

댓글을 달아 주세요

로그인 ROLE에 따라 특정 메뉴 보이기/숨기기

 

 

1. pom.xml 확인

<dependency>

<groupId>egovframework.rte</groupId>

<artifactId>egovframework.rte.fdl.security</artifactId>

<version>${egovframework.rte.version}</version>

 

</dependency>

 

2. jsp 파일


<%@ taglib uri="http://www.springframework.org/security/tags" prefix="sec" %>



<!-- 관리자 로그인 중-->

<sec:authorize access="hasRole('ROLE_ADMIN')">

<button>관리자접속중</button>

</sec:authorize>  


<!-- 로그인 전 -->

<sec:authorize access="isAnonymous()">

<button>로그인하세요.</button>

</sec:authorize>


<!-- 사용자 로그인 중 -->

<sec:authorize access="isAuthenticated()">

<button>로그인하세요.</button>

</sec:authorize>




* 추가 표현들


hasRole([role])특정한 롤을 가지고 있는 경우 true
hasAnyRole([role1,role2])복수의 롤을 가지고 있는 경우 true
principalAllows direct access to the principal object representing the current user
authenticationAllows direct access to the current Authentication object obtained from the SecurityContext
permitAllAlways evaluates to true
denyAllAlways evaluates to false
isAnonymous()Returns true if the current principal is an anonymous user
isRememberMe()Returns true if the current principal is a remember-me user
isAuthenticated()Returns true if the user is not anonymous
isFullyAuthenticated()Returns true if the user is not an anonymous or a remember-me user



블로그 이미지

엘로드넷

댓글을 달아 주세요

서버환경 : 

Windows Server 2016 64bit

JDK가 설치되어 있어야 한다.

 

 

 

1. 톰캣 다운로드

 

http://tomcat.apache.org

 

64-bit Windows zip 을 다운로드 받는다.

 

5e30bf3087ef5aed6fa37887eea01326_1542681643_656.png
 

 

 

 

2. 압축풀어서 적당한 곳에 위치시킨다.

 

C:\Program Files\Apache Software Foundation 폴더에 

 

apache-tomcat-8.0.531

apache-tomcat-8.0.532

 

와 같이 다른 이름으로 압축을 풀어준다.

 

현재로선 두 폴더의 내용은 동일하다.

 

 

5e30bf3087ef5aed6fa37887eea01326_1542687956_8318.png
 

 

 

 

 

 

3. 첫번째 서버 포트를 구성한다.

 

3.1 server.xml를 수정한다.

 

apache-tomcat-8.0.531/conf/server.xml

 

 

수정할 부분은 아래와 같다.(빨간색)

서버2와 중복되지 않는 것으로 설정한다.

테스트이므로 서버1은 톰캣 기본 설정 그대로 둔다.

 

 

 

<?xml version='1.0' encoding='utf-8'?>

 

<Server port="8005" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />

 

  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />

  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

 

 

  <GlobalNamingResources>

 

    <Resource name="UserDatabase" auth="Container"

              type="org.apache.catalina.UserDatabase"

              description="User database that can be updated and saved"

              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

              pathname="conf/tomcat-users.xml" />

  </GlobalNamingResources>

 

 

  <Service name="Catalina">

 

 

    <Connector port="8080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443" />

  

 

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

 

 

    <Engine name="Catalina" defaultHost="localhost">

 

      <Realm className="org.apache.catalina.realm.LockOutRealm">

 

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

               resourceName="UserDatabase"/>

      </Realm>

 

      <Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true">

 

 

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

               prefix="localhost_access_log" suffix=".txt"

               pattern="%h %l %u %t "%r" %s %b" />

 

      </Host>

    </Engine>

  </Service>

</Server>


 

 

3.2 startup.bat 파일을 수정한다.

 

apache-tomcat-8.0.531/bin/startup.bat



아래 빨간색과 같이 추가해 준다.

 

 

 

@echo off

rem Licensed to the Apache Software Foundation (ASF) under one or more

rem contributor license agreements.  See the NOTICE file distributed with

rem this work for additional information regarding copyright ownership.

rem The ASF licenses this file to You under the Apache License, Version 2.0

rem (the "License"); you may not use this file except in compliance with

rem the License.  You may obtain a copy of the License at

rem

rem     http://www.apache.org/licenses/LICENSE-2.0

rem

rem Unless required by applicable law or agreed to in writing, software

rem distributed under the License is distributed on an "AS IS" BASIS,

rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

rem See the License for the specific language governing permissions and

rem limitations under the License.

 

rem ---------------------------------------------------------------------------

rem Start script for the CATALINA Server

rem ---------------------------------------------------------------------------

 

 

set "CATALINA_HOME=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.531"

set "CATALINA_BASE=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.531"

set "SERVER_NAME=Server1"

set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191"

 

 

setlocal


 

 

3.3 shutdown.bat 파일을 수정한다.

apache-tomcat-8.0.531/bin/shutdown.bat



startup.bat 파일과 마찬가지로 아래처럼 추가해 준다.

 

 

@echo off

rem Licensed to the Apache Software Foundation (ASF) under one or more

rem contributor license agreements.  See the NOTICE file distributed with

rem this work for additional information regarding copyright ownership.

rem The ASF licenses this file to You under the Apache License, Version 2.0

rem (the "License"); you may not use this file except in compliance with

rem the License.  You may obtain a copy of the License at

rem

rem     http://www.apache.org/licenses/LICENSE-2.0

rem

rem Unless required by applicable law or agreed to in writing, software

rem distributed under the License is distributed on an "AS IS" BASIS,

rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

rem See the License for the specific language governing permissions and

rem limitations under the License.

 

rem ---------------------------------------------------------------------------

rem Stop script for the CATALINA Server

rem ---------------------------------------------------------------------------

 

set "CATALINA_HOME=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.531"

set "CATALINA_BASE=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.531"

set "SERVER_NAME=Server1"

set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191"

 

setlocal

 

 

 

3.4 service.bat 파일을 수정한다.

 

apache-tomcat-8.0.531/bin/service.bat


80줄 근처의 아래 항목을 찾아서 변경해 준다.

rem Set default Service name
set SERVICE_NAME=Tomcat81
set DISPLAYNAME=Apache Tomcat 8.0 %SERVICE_NAME% Server1

 

 

서비스에 등록한다.

 

 

5e30bf3087ef5aed6fa37887eea01326_1542688166_8261.png
 

 

 

 

 

 

 

 

 

 

4. 두번째 서버 포트를 구성한다.

 

4.1 server.xml를 수정한다.

 

apache-tomcat-8.0.532/conf/server.xml

 

 

수정할 부분은 아래와 같다.(빨간색)

서버1과 중복되지 않는 것으로 설정한다.

 

 

 

<?xml version='1.0' encoding='utf-8'?>

 

<Server port="9005" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />

 

  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />

  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

 

 

  <GlobalNamingResources>

 

    <Resource name="UserDatabase" auth="Container"

              type="org.apache.catalina.UserDatabase"

              description="User database that can be updated and saved"

              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

              pathname="conf/tomcat-users.xml" />

  </GlobalNamingResources>

 

 

  <Service name="Catalina">

 

 

    <Connector port="9080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="9443" />

  

 

    <Connector port="9009" protocol="AJP/1.3" redirectPort="9443" />

 

 

    <Engine name="Catalina" defaultHost="localhost">

 

      <Realm className="org.apache.catalina.realm.LockOutRealm">

 

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

               resourceName="UserDatabase"/>

      </Realm>

 

      <Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true">

 

 

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

               prefix="localhost_access_log" suffix=".txt"

               pattern="%h %l %u %t "%r" %s %b" />

 

      </Host>

    </Engine>

  </Service>

</Server>


 

 

4.2 startup.bat 파일을 수정한다.

 

apache-tomcat-8.0.532/bin/startup.bat

 

 

 

아래 빨간색과 같이 추가해 준다.

 

 

 

@echo off

rem Licensed to the Apache Software Foundation (ASF) under one or more

rem contributor license agreements.  See the NOTICE file distributed with

rem this work for additional information regarding copyright ownership.

rem The ASF licenses this file to You under the Apache License, Version 2.0

rem (the "License"); you may not use this file except in compliance with

rem the License.  You may obtain a copy of the License at

rem

rem     http://www.apache.org/licenses/LICENSE-2.0

rem

rem Unless required by applicable law or agreed to in writing, software

rem distributed under the License is distributed on an "AS IS" BASIS,

rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

rem See the License for the specific language governing permissions and

rem limitations under the License.

 

rem ---------------------------------------------------------------------------

rem Start script for the CATALINA Server

rem ---------------------------------------------------------------------------

 

 

set "CATALINA_HOME=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.532"

set "CATALINA_BASE=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.532"

set "SERVER_NAME=Server2"

set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191"

 

 

setlocal

 

 

 

 

4.3 shutdown.bat 파일을 수정한다.

apache-tomcat-8.0.532/bin/shutdown.bat



startup.bat 파일과 마찬가지로 아래처럼 추가해 준다.

 

 

@echo off

rem Licensed to the Apache Software Foundation (ASF) under one or more

rem contributor license agreements.  See the NOTICE file distributed with

rem this work for additional information regarding copyright ownership.

rem The ASF licenses this file to You under the Apache License, Version 2.0

rem (the "License"); you may not use this file except in compliance with

rem the License.  You may obtain a copy of the License at

rem

rem     http://www.apache.org/licenses/LICENSE-2.0

rem

rem Unless required by applicable law or agreed to in writing, software

rem distributed under the License is distributed on an "AS IS" BASIS,

rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

rem See the License for the specific language governing permissions and

rem limitations under the License.

 

rem ---------------------------------------------------------------------------

rem Stop script for the CATALINA Server

rem ---------------------------------------------------------------------------

 

set "CATALINA_HOME=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.532"

set "CATALINA_BASE=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.532"

set "SERVER_NAME=Server2"

set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191"

 

setlocal

 

 

 

3.4 service.bat 파일을 수정한다.

 

apache-tomcat-8.0.531/bin/service.bat


80줄 근처의 아래 항목을 찾아서 변경해 준다.

rem Set default Service name
set SERVICE_NAME=Tomcat82
set DISPLAYNAME=Apache Tomcat 8.0 %SERVICE_NAME% Server2

 

 

서비스에 등록한다.

 

 

5e30bf3087ef5aed6fa37887eea01326_1542688233_0907.png
 

 

 

 

5. 서버1, 서버2를 시작한다.

 

작업관리자 > 서비스 항목에 간다.

 

Tomcat81, Tomcat82 항목을 찾아 마우스 우측 클릭 > 시작을 클릭한다.

 

5e30bf3087ef5aed6fa37887eea01326_1542688342_1742.png
 

 

 

 

6. 브라우저에서 접속해 본다.

8080, 9080 동일하게 나올 것이다.

 

 

5e30bf3087ef5aed6fa37887eea01326_1542688450_991.png
 

 

 

 

 

 

끝.

 

블로그 이미지

엘로드넷

댓글을 달아 주세요

톰캣 ROOT로 배포하기

JAVA 2019. 1. 8. 21:51

1. 이클립스에서 export 한 war파일을 ROOT.war 로 이름을 변경한다.

 

 

2. 톰캣이 가동중이면 중지한다.

 

 

3. 톰캣 webapps 폴더에 있는 ROOT폴더를 이름변경 또는 삭제한다.(ROOTOLD로 변경하였다.)

톰캣 webapps 폴더에 ROOT.war 파일을 위치시킨다. 

 

 

4. 톰캣을 가동한다.

 

ROOT.war 파일이 압축이 자동으로 풀리면서 ROOT 폴더가 생성된다.

 

 

5e30bf3087ef5aed6fa37887eea01326_1542688849_2517.png
 

 

5. ROOT.war파일을 삭제한다.

 

 

6. 브라우저에서 접속해 본다.

 

블로그 이미지

엘로드넷

댓글을 달아 주세요

1. globals.propeties에 접속정보 추가

경로 : /src/main/reousrces/egovframework/egovProps/globals.properties 





#oracle DB2

Globals.DB2.DriverClassName=oracle.jdbc.driver.OracleDriver

Globals.DB2.Url=jdbc:oracle:thin:@127.0.0.1:1521:ORCL 

Globals.DB2.UserName=아이디

Globals.DB2.Password=비밀번호






2. context-datasource.xml 에 추가

경로 : /src/main/reousrces/egovframework/spring/com/context-datasource.xml




    

    <!-- Oracle DB2 -->

    <bean id="dataSource-DB2" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

        <property name="driverClassName" value="${Globals.DB2.DriverClassName}"/>

        <property name="url" value="${Globals.DB2.Url}" />

        <property name="username" value="${Globals.DB2.UserName}"/>

        <property name="password" value="${Globals.DB2.Password}"/>

        <property name="initialSize" value="0"/>

        <property name="maxActive" value="2"/>

        <property name="maxIdle" value="2"/>

        <property name="minIdle" value="0"/>

        <property name="maxWait" value="-1"/>

    </bean>    

    

 


3. context-sqlMap.xml 에 추가

경로 : /src/main/reousrces/egovframework/spring/com/context-sqlMap.xml



        

    <!-- SqlMap setup for iBATIS Database Layer -->

    <bean id="DB2.sqlMapClient" class="egovframework.rte.psl.orm.ibatis.SqlMapClientFactoryBean">

        <property name="configLocations">

            <list>

                <value>classpath:/egovframework/sqlmap/config/DB2/*.xml</value>

            </list>

        </property>

        <property name="dataSource" ref="dataSource-DB2"/>

        <property name="lobHandler" ref="lobHandler"/>

    </bean>





4. sqlmap/config에 추가


경로 : /src/main/reousrces/egovframework/spring/sqlmap/config/DB2/sql-map-config-oracle-DB2.xml


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

<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"

    "http://www.ibatis.com/dtd/sql-map-config-2.dtd">


<sqlMapConfig>

<sqlMap resource="egovframework/sqlmap/DB2/DB2_SQL_Oracle.xml"/>

</sqlMapConfig> 





5. DB2_SQL_Oracle.xml 생성


경로 : /src/main/reousrces/egovframework/spring/sqlmap/DB2/DB2_SQL_Oracle.xml


내용은 기존 방식과 동일







6. EgovAbstractDAO를 상속받는 abstract DAO 클래스 생성


적절한 service 패키지 내에 생성한다.



public abstract class EgovDBSecondAbstractDAO extends EgovAbstractDAO {


@Override

@Resource(name = "DB2.sqlMapClient")

public void setSuperSqlMapClient(SqlMapClient sqlMapClient) {

super.setSuperSqlMapClient(sqlMapClient);

}


}





7. DAO클래스 생성


import 서비스위치.EgovDBSecondAbstractDAO;


@Repository("dbSecondDAO")

public class DbSecondDAO extends EgovDBSecondAbstractDAO{



    public List<?> selectUser(String uniqId){

        return List<?> select("dbSecondDAO.selectUser", uniqId);

    }


}





8. ServiceImpl 설정



@Service("testService")

public class TestServiceImpl extends EgovAbstractServiceImpl implements TestService {


/** dbSecondDAO */

@Resource(name="dbSecondDAO")

private DbSecondDAO dbSecondDAO;


@Override

public List<?> selectUser(String uniqId) {

List<?> resultList = dbSecondDAO.selectUser(uniqId);

return resultList;

}






9. 컨트롤러내 추가(기존 방식과 동일)


/** testService */

@Resource(name = "testService")

private TestService testService;



@RequestMapping(value = "/test/list.do", method=RequestMethod.GET)

public String selectUserList(@RequestParam(value = "uniqId", required = false) final String uniqId, ModelMap model) throws Exception {


List<?> resultList = testService.selectUser(uniqId); 

model.addAttribute("resultList"resultList);


}




끝.



블로그 이미지

엘로드넷

댓글을 달아 주세요

1. globals.propeties에 접속정보 추가

경로 : /src/main/reousrces/egovframework/egovProps/globals.properties 




#ms-sql:DB

Globals.ms.DriverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver

Globals.ms.Url=jdbc:sqlserver://127.0.0.1:1433;databaseName=디비명 

Globals.ms.UserName=사용자

Globals.ms.Password=비밀번호






2. context-datasource.xml 에 추가

경로 : /src/main/reousrces/egovframework/spring/com/context-datasource.xml



    <alias name="dataSource-ms" alias="ms.dataSource" />


    

    <bean id="dataSource-ms" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

        <property name="driverClassName" value="${Globals.ms.DriverClassName}"/>

        <property name="url" value="${Globals.ms.Url}" />

        <property name="username" value="${Globals.ms.UserName}"/>

        <property name="password" value="${Globals.ms.Password}"/>

        <property name="initialSize" value="0"/>

        <property name="maxActive" value="1"/>

        <property name="maxIdle" value="1"/>

        <property name="minIdle" value="0"/>

        <property name="maxWait" value="-1"/>

    </bean>

 

 


3. context-sqlMap.xml 에 추가

경로 : /src/main/reousrces/egovframework/spring/com/context-sqlMap.xml



        

    <bean id="ms.sqlMapClient" class="egovframework.rte.psl.orm.ibatis.SqlMapClientFactoryBean">

        <property name="configLocations">

            <list>

                <value>classpath:/egovframework/sqlmap/config/ms/*.xml</value>

            </list>

        </property>

        <property name="dataSource" ref="dataSource-ms"/>

        <property name="lobHandler" ref="lobHandler"/>

    </bean>




4. sqlmap/config에 추가


경로 : /src/main/reousrces/egovframework/spring/sqlmap/config/ms/sql-map-config-ms.xml


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

<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"

    "http://www.ibatis.com/dtd/sql-map-config-2.dtd">


<sqlMapConfig>

<sqlMap resource="egovframework/sqlmap/ms/SQL_Ms.xml"/>

</sqlMapConfig> 





5. SQL_Ms.xml 생성


경로 : /src/main/reousrces/egovframework/spring/sqlmap/ms/SQL_Ms.xml


내용은 기존 방식과 동일







6. EgovAbstractDAO를 상속받는 DAO 클래스 생성


적절한 service 패키지 내에 생성한다.



public class EgovMssqlAbstractDAO extends EgovAbstractDAO {


@Override

@Resource(name = "ms.sqlMapClient")

public void setSuperSqlMapClient(SqlMapClient sqlMapClient) {

super.setSuperSqlMapClient(sqlMapClient);

}


}





7. DAO클래스 생성


import 서비스위치.EgovMssqlAbstractDAO;


@Repository("mssqlDAO")

public class MssqlDAO extends EgovMssqlAbstractDAO{



    public List<?> selectUser(String uniqId){

        return List<?> select("mssqlDAO.selectUser"uniqId);

    }


}





8. ServiceImpl 설정



@Service("testService")

public class TestServiceImpl extends EgovAbstractServiceImpl implements TestService {


/** mssqlDAO */

@Resource(name="mssqlDAO")

private MssqlDAO mssqlDAO;


@Override

public List<?> selectUser(String uniqId) {

List<?> resultList = mssqlDAO.selectUser(uniqId);

return resultList;

}






9. 컨트롤러내 추가(기존 방식과 동일)


/** testService */

@Resource(name = "testService")

private TestService testService;



@RequestMapping(value = "/test/list.do", method=RequestMethod.GET)

public String selectUserList(@RequestParam(value = "uniqId", required = falsefinal String uniqId, ModelMap modelthrows Exception {


List<?> resultList = testService.selectUser(uniqId); 

model.addAttribute("resultList"resultList);


}




끝.

블로그 이미지

엘로드넷

댓글을 달아 주세요

프로시저명 : sp_test



1. DAO


select 로 호출함



    public void callSP() {

    

     select("testDAO.callSP");

    }




2. ibatis xml 


<procedure></procedure> 태그를 사용함



<procedure id="testDAO.callSP" > 

<![CDATA[

{ CALL sp_test }

]]>

</procedure>



끝.


블로그 이미지

엘로드넷

댓글을 달아 주세요