순차적으로 요소를 제거 한다.


샘플 코드


var testArr =[1, 2, 3, 4, 5, 6];


testArr.shift();

console.log(testArr);



실행 화면


[ 2, 3, 4, 5, 6 ]



참고 사이트:  http://www.w3schools.com/jsref/jsref_shift.asp



nodejs, npm이 설치 되어 있다고 가정 한다.

매번 컴파일 해야 하는 부담감을 줄여주고 새로 작성된 코드를 자동으로 컴파일 해준다.


Step 1.  nodemon 설치하기

npm grobal 옵션을 사용하여 설치 한다.



whitelife@whitelife-note:~/workspace/HelloWorld$ sudo npm install nodemon -g
[sudo] password for whitelife:
npm http GET https://registry.npmjs.org/nodemon
npm http 304 https://registry.npmjs.org/nodemon
/usr/bin/nodemon -> /usr/lib/node_modules/nodemon/nodemon.js
nodemon@0.7.2 /usr/lib/node_modules/nodemon


Step 2.  테스트 하기

node xxx.js -> nodemon xxx.js 로 실행 한다. 소스가 수정 될 경우 자동으로 적용 된다.



whitelife@whitelife-note:~/workspace/HelloWorld$ nodemon index.js
4 Feb 15:37:25 - [nodemon] v0.7.2
4 Feb 15:37:25 - [nodemon] watching: /home/whitelife/workspace/HelloWorld
4 Feb 15:37:25 - [nodemon] starting `node index.js`
Server has started.


// ...


4 Feb 15:43:03 - [nodemon] starting `node index.js`
Server has started.


'Nodejs' 카테고리의 다른 글

Html을 Jade로 변환하기  (0) 2013.02.06
Nodejs의 의미와 자바의 대안  (0) 2013.02.05
[스크랩] 완벽 튜토리얼 정리  (0) 2013.02.04
Nodejs로 WebServer 띄우기  (0) 2012.11.18
Nodejs로 Hello World! 띄우기  (0) 2012.11.18


http://crazia.tistory.com/entry/Nodejs-%EC%99%84%EB%B2%BD-%ED%8A%9C%ED%86%A0%EB%A6%AC%EC%96%BC-%EC%A0%95%EB%A6%AC


기초 부터 잘 정리 되어 있음 ~


'Nodejs' 카테고리의 다른 글

Html을 Jade로 변환하기  (0) 2013.02.06
Nodejs의 의미와 자바의 대안  (0) 2013.02.05
nodemon 사용하기  (0) 2013.02.04
Nodejs로 WebServer 띄우기  (0) 2012.11.18
Nodejs로 Hello World! 띄우기  (0) 2012.11.18


http://crazia.tistory.com/entry/%ED%8D%BC%EC%98%A8%EA%B2%83-%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EB%A1%9C%EB%B6%80%ED%84%B0-%EB%B0%B0%EC%9A%B0%EB%8A%94-%EC%BD%94%EB%94%A9-%EA%B8%B0%EC%88%A0


그림으로 설명이 잘 되어 있다. 도움이 많이 될 꺼 같음 !!!


VirtualBox는 설치 되어 있다고 가정 한다. 설치 되어 있지 않은 경우 VirtualBox 설치 하기 글을 참고 하자.


Step 1.  ubuntu 다운 받기 (12.10)

설치 주소


  1. 32bit: http://www.ubuntu.com/download/desktop/thank-you?release=latest&bits=32&distro=desktop&status=zeroc
  2. 64bit: http://www.ubuntu.com/download/desktop/thank-you?release=latest&bits=64&distro=desktop&status=zeroc


ubuntu-12.10 iso 이미지가 다운로드 될 것이다.


Step 2.  가상 머신 만들기

VirtualBox를 실행 한다.



왼쪽 상단에 있는 아이콘을 클릭 한다.



설정 목록


  • 이름 : 저장될 가상머신 명
  • 종류 : OS 명
  • 버전 : OS 종류, 비트 수

위 목록에 대한 선택을 한다.

Step 3.  메모리 설정 하기
용도에 적당하게 메모리를 부여 한다.


Step 4.  하드 드라이브 설정 하기

가상 하드 드라이브를 생성 한다.





여유 있게 하드 드라이브 용량을 설정 한다.


드라이브 만드는 중...


드라이브 만들기가 완료 되면 가상 머신이 생성 된다.


Step 5.  ubuntu iso 파일 넣기
실행 절차

  1. 가상 머신 아이콘에서 마우스 오른쪽 설정 클릭
  2. CD 모양 비어있음 클릭
  3. CD 모양 아이콘을 클릭 한후, 다운 받은 ubuntu iso 파일을 넣는다.


iso 파일이 정상적으로 인식 했는지 확인


Step 6.  가상 머신 부팅 및 설치

정상적으로 부팅이 되면 아래와 같은 화면이 나타난다.

그림에 따라 순차적으로 진행 한다.





계속 버튼을 클릭 하면 본격적으로 복사가 시작 된다.


기본 정보를 입력 한다. 순차적으로 진행 하면 된다.


설치가 완료 되면 아래와 같은 메시지가 뜬다. 재부팅을 하자.


아래와 같은 화면이 나오면 성공이다.







'Linux' 카테고리의 다른 글

NateOn Linux에 설치 하기  (0) 2013.02.10
mint 한글 설정 하기 (Maya)  (0) 2013.02.10
VirtualBox 설치 하기  (0) 2013.02.04
CentOS 에서 부팅 시 시작스크립트 등록 하기  (0) 2012.11.26
CentOS 에서 Hostname 설정 하기  (0) 2012.11.25


가상으로 OS를 체험할 수 있는 VirtualBox를 설치 해보자. Windows 기준으로 설명 한다.


Step 1.  VirtualBox 다운 받기

https://www.virtualbox.org/wiki/Downloads로 접속 한 후, 각 OS 버전에 맞는 설치 파일을 다운로드 한다.



Step 2.  다운 받은 파일 VirtualBox-4.2.6-82870-Win.exe를 실행 한다.

윈도우 버전은 긍정적인 답변을 하면 쉽게 설치가 완료 된다.



Step 3.  VirtualBox 실행

네트워크 및 인터넷 > 네트워크 연결 > 어댑터 설정 변경을 보면 VirtualBox Network를 확인 할 수 있다.


        


시작 메뉴에 있는 VirtualBox 를 실행 한다.



위 화면이 나왔다면 성공이다.




Tomcat7은 설치 되어 있다고 가정 한다. War 파일도 준비해야 한다.


Step 1.  Admin 계정 만들기

D:\Develop\was\tomcat\apache-tomcat-7.0.35\conf\tomcat-users.xml 파일을 수정 하자.



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

<!--

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

  contributor license agreements.  See the NOTICE file distributed with

  this work for additional information regarding copyright ownership.

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

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

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


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


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

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

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

  See the License for the specific language governing permissions and

  limitations under the License.

-->

<tomcat-users>

<!--

  NOTE:  By default, no user is included in the "manager-gui" role required

  to operate the "/manager/html" web application.  If you wish to use this app,

  you must define such a user - the username and password are arbitrary.

-->

<!--

  NOTE:  The sample user and role entries below are wrapped in a comment

  and thus are ignored when reading this file. Do not forget to remove

  <!.. ..> that surrounds them.

-->

<!--

  <role rolename="tomcat"/>

  <role rolename="role1"/>

  <user username="tomcat" password="tomcat" roles="tomcat"/>

  <user username="both" password="tomcat" roles="tomcat,role1"/>

  <user username="role1" password="tomcat" roles="role1"/>

-->

<role rolename="manager-gui" />

      <user username="min" password="min" roles="manager-gui" />


</tomcat-users>



관리자에 해당하는 권한을 주고 아이디를 생성 했다.


Step 2.  서버 시작 하기


  • Windows -> D:\Develop\was\tomcat\apache-tomcat-7.0.35\bin\startup.bat
  • Linux -> D:\Develop\was\tomcat\apache-tomcat-7.0.35\bin\startup.sh

OS에 맞는 파일을 실행 한다. 


2013. 2. 1 오후 3:04:24 org.apache.catalina.core.AprLifecycleListener init
정보: Loaded APR based Apache Tomcat Native library 1.1.24 using APR version 1.4.6.
2013. 2. 1 오후 3:04:24 org.apache.catalina.core.AprLifecycleListener init
정보: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2013. 2. 1 오후 3:04:24 org.apache.catalina.core.AprLifecycleListener initializeSSL
정보: OpenSSL successfully initialized (OpenSSL 1.0.1c 10 May 2012)
2013. 2. 1 오후 3:04:25 org.apache.coyote.AbstractProtocol init
정보: Initializing ProtocolHandler ["http-apr-8080"]
2013. 2. 1 오후 3:04:25 org.apache.coyote.AbstractProtocol init
정보: Initializing ProtocolHandler ["ajp-apr-8009"]
2013. 2. 1 오후 3:04:25 org.apache.catalina.startup.Catalina load
정보: Initialization processed in 1208 ms
2013. 2. 1 오후 3:04:25 org.apache.catalina.core.StandardService startInternal
정보: Starting service Catalina
2013. 2. 1 오후 3:04:25 org.apache.catalina.core.StandardEngine startInternal
정보: Starting Servlet Engine: Apache Tomcat/7.0.35
2013. 2. 1 오후 3:04:25 org.apache.catalina.startup.HostConfig deployWAR
정보: Deploying web application archive D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\ROOT.war
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.HostConfig deployDirectory
정보: Deploying web application directory D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\docs
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.HostConfig deployDirectory
정보: Deploying web application directory D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\examples
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.HostConfig deployDirectory
정보: Deploying web application directory D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\host-manager
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.HostConfig deployDirectory
정보: Deploying web application directory D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\manager
2013. 2. 1 오후 3:04:26 org.apache.coyote.AbstractProtocol start
정보: Starting ProtocolHandler ["http-apr-8080"]
2013. 2. 1 오후 3:04:26 org.apache.coyote.AbstractProtocol start
정보: Starting ProtocolHandler ["ajp-apr-8009"]
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.Catalina start
정보: Server startup in 1546 ms


Step 3.  관리자 페이지 접속 하기

따로 설정을 하지 않았다면 http://localhost:8080/manager 로 접속 한다.



방금 만들었던 Admin 계정을 입력 한다.



위와 같은 페이지가 뜨면 성공 이다. Applications 현황이나, Server Status를 볼 수 있다. 


Step 4.  War Deploy 하기

스크롤을 내리다 보면 아래와 같은 메뉴가 있다.



실행 절차


  1. 찾아보기 버튼을 클릭하여 War 파일을 추가 한다.
  2. Deploy 버튼을 클릭 한다.

참고) War 파일의 이름이 Context Path 가 된다. 아래 그림에 /whitelife 라고 추가 된 것을 볼 수 있다.



2013. 2. 1 오후 3:18:11 org.apache.catalina.startup.HostConfig deployWAR

정보: Deploying web application archive D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\whitelife.war



정상적으로 Deploy가 된 경우, Applications 제일 밑에 추가 된 것을 볼 수 있다.

상황에 따라서 해당 Application을 Stop, Reload, Undeploy 할 수 있다.


Step 5.  Hello World !!! 확인하기


위 페이지가 떳다면 성공이다. 



[projectName]-servlet.xml 파일에 추가 하도록 하자.


Resolve 1.  모든 요청에 따른 Interceptor 적용


<!-- Interceptor -->

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">

<property name="interceptors">

<list>

<ref bean="kr.co.whitelife.WhitelifeInterceptor"/>

<ref bean="kr.co.whitelife.BlacklifeInterceptor"/>

</list>

</property>

</bean>



모든 요청에 대한 응답을 해주는 DefaultAnnotationHandlerMapping을 이용 한다. 다 수의 Interceptor를 순차적으로 적용이 가능하다.


Resolve 2.  일부 요청에 따른 Interceptor 적용


<!-- Interceptor -->

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">

<property name="mappings">

<props>

<prop key="/test">WhitelifeController</prop>

</props>

</property>

<property name="interceptors">

<ref bean="WhitelifeInterceptor"/>

</property>

</bean>



RequestUri에 따른 Controller 분기가 가능한 SimpleUrlHandlerMapping을 이용 했다. Resolve 1 방법과 같은 방법으로 Interceptor을 적용이 가능하다.


Resolve 3.  mvc 태그를 이용 하는 방법


<mvc:interceptors>

<bean class="kr.co.whitelife.WhitelifeInterceptor"/>

<bean class="kr.co.whitelife.Blacklifenterceptor"/>

<mvc:interceptor>

<mvc:mapping path="/test/*"/>

<bean class="kr.co.whitelife.WhitelifeInterceptor"/>

</mvc:interceptor>

</mvc:interceptors>



Spring 3.x 버전 이후로는 mvc 전용 태그를 지원 한다. 2~3번째 줄에 있는 부분은 Resolve 1 방법, 4~7번째 줄에 있는 부분은 Resolve 2 방법과 같다. 


Interceptor Class Sample


/**

 * Sample Interceptor

 * @author whitelife

 * @since 2013-01-31

 */

@Controller("TestInterceptor")

public class TestInterceptor extends HandlerInterceptorAdapter {


@Override

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

System.out.println("TestInterceptor{preHandle}............................................ start");

return true;

}


@Override

public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {

System.out.println("TestInterceptor{postHandle}............................................ end");

}

}




Interceptor도 Controller과 마찬가지로 RequestUri에 따라 분기를 하기 때문에 Controller과 같은 동작을 한다. @Controller도 적용이 가능하다.




+ Recent posts