public class StringFinder {
    public static void main(String[] args) {

        String txt1 = "가나다라" ;
        String txt2 = "해당 내용은 테스트 입니다" ;
        String txt3 = "가격은 29,000원 입니다" ;

        // contains를 이용한 방법(true, false 반환)
        if(txt1.contains("나다"))
            System.out.println("문자열 있음!");
        else
            System.out.println("문자열 없음!");
         
         
        // indexOf를 이용한 방법
        if(txt2.indexOf("테스트") > -1)
            System.out.println("문자열 있음!");
        else
            System.out.println("문자열 없음!");
         
         
        // matches를 이용한 방법
        if(txt2.matches(".*테스트.*"))
            System.out.println("문자열 있음!");
        else
            System.out.println("문자열 없음!");
         
         
        // matches를 이용하여 정규 표현식으로 문자열에 숫자가 있는지 확인
        if(txt3.matches(".*[0-9].*"))
            System.out.println("숫자 있음!");
        else
            System.out.println("숫자 없음!");
    }
}

contains문자열에 검색하고자 하는 문자가 있는지 확인 : 포함 - true / 미포함 - false
indexOf 문자열에서 검색하는 문자의 위치를 반환 : 포함 - 문자 위치 / 미포함 - ( -1 )
matches 정규식을 이용하여 문자열을 검색한다, 특정 문자열을 검색할때 사용하기 보다는 한글, 숫자 등과 같이 해당 형태의 텍스트가 존재하는지 확인할때 사용하면 좋다 : 포함 - true / 미포함 - false



출처 : http://fruitdev.tistory.com/72


'Server Enterprise > Java' 카테고리의 다른 글

[Java] Design Pattern  (0) 2016.07.07
[Book] 알고리즘 관련 서적 for java  (0) 2016.07.05
[random] java.security.SecureRandom  (0) 2016.01.12
[Request] 호스트 설정 jsp  (0) 2016.01.12
URL Encoding 특수문자 코드  (0) 2015.07.22



SecureRandom random = new SecureRandom ();

//랜던 문자 길이

int numLength = 16;

String randomStr = "";


for (int i = 0; i < numLength; i++) {

//0 ~ 9 랜덤 숫자 생성

//randomStr += ran.nextInt(10);

randomStr += random.nextInt(10);

System.out.println("randomStr "+ i + " :: " + randomStr);

}




아래 출처 : https://jonghwasu.wordpress.com/2013/02/15/%EA%B0%95%EB%A0%A5%ED%95%9C-%EB%82%9C%EC%88%98%EB%A5%BC-%EC%83%9D%EC%84%B1-%ED%95%9C%EB%8B%A4/



  • 강력한 난수를 생성한다.
    • 의사 난수 생성기는 좋은 통계적 성질을 가진 일련의 수 배열을 생성하는 결정성 수학 알고리즘을 사용
    • 그러나 숫자 배열이 진정한 난수성을 갖지는 않는다.
    • 의사 난수 생성기는 일반적으로 초깃값(seed value)으로 시작한다.
    • 알고리즘은 이 초깃값을 사용해 난수를 생성하고 새로운 초깃 값을 만들고, 다시 이 초깃 값을 사용해 그 다음 난 수 값을 만든다.
  • 자바 API는 java.util.Random 클래스로 의사 난수 생성기를 구현한다.
    • 의사 난수 생성기는 이식 할 수 있고 반복될 수 있다.
    • 따라서 동일한 초깃값을 사용해 생성한 두개의 java.util.Random 객체는 모든 자바 구현에서 동일한 숫자 배열을 생성하게 된다.
    • 어플리케이션을 초기화 하거나 시스템이 재 시동된 후에 초깃값이 재 사용되곤 한다.
    • 또는 시스템 클럭에서 가져온 현재 시간에서 유도하여 초깃 값으로 사용하기도 한다.
  • 부적합 코드예
    • 이 클래스는 모든 주어진 초깃 값에 대해 동일한 숫자 배열을 생성한다. 따라서 앞으로 나올 숫자를 예상 할 수 있다.
    1
    2
    3
    4
    5
    6
    Random rand1 = new Random(123L);
     
    /* [0,20] 범위에 있는 또다른 정수현 난수를 생성한다. */
    int n = rand1.nextInt(21);
    System.out.println("Random1 =================================================");
    System.out.println(n);
  • 적합 코드 예
  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    /* java.security.SecureRandom 클래스를 사용해 고품질의 난수를 만들어낸다. */
    SecureRandom rand3 = null;
    try {
        rand3 = SecureRandom.getInstance("SHA1PRNG");
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
     
    System.out.println("SecureRandom============================================");
    n = rand3.nextInt(21);
    System.out.println(n);
  • 적합 코드 예
  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    /* Random의 기본 생성자를 이용하면 생성자를 호출 할 때 마다 다른 값을 초기 값으로 가져올 수 있다. */
    Random rand2 = new Random();
    System.out.println("Random2 =================================================");
    for(int i = 0; i < 20; i++) {
        /* 난수 생성기의 초깃값을 다시 설정 */
        rand2 = new Random();
        n = rand1.nextInt(21);
        System.out.println(n);
    }

String svrHost = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();

print) svrHost    ::    http://localhost:8080


if (svrHost.matches("(?i).*127.0.0.1:8080.*")){ // (?i).*내용.* ==> 대소문자 구분없이

// local logic

} else if (svrHost.matches("(?i).*10.185.130.23:6010.*")) {

// dev logic

else if (svrHost.matches("(?i).*http://www.domain.co.kr.*") || svrHost.matches("(?i).*http://domain.co.kr.*")) {

// http prd logic

} else if (svrHost.matches("(?i).*https://www.domain.co.kr.*") || svrHost.matches("(?i).*https://domain.co.kr.*")) {

// https prd logic

} else { }



ServletRequest와 HttpServletRequest의 구분

 

 ServletRequest는 기본적인 클라이언트 요청에 관한 모든 정보를 가지고 있습니다. 그리고 이 인터페이스는 다시 HttpServletRequest로 확장하여 HTTP프로토콜상에서 할 수 있는 일들이 포함되어져 있습니다. 이 HttpServletRequest는 서블릿의 service의 매개변수의 하나로 서블릿 프로그래머가 클라이언트의 요청에 관한 작업들을 핸들할 수 있도록 하는 중요한 역할을 담당하고 있습니다. ServletRequest인터페이스의 구조를 살펴보면 다음과 같은 부분으로 나눌 수 있습니다.

 

ServletRequest의 구조

n        클라이언트 자체에 대한 정보추출

n        클라이언트가 전송한 정보 추출

 

 이러한 구조에 따라서 ServletRequest의 메서드를 분류해 보면 다음과 같습니다.

 

ServletRequest의 멤버메서드

클라이언트 자체에 대한 정보추출

Object getAttribute(String name): 주어진 이름을 갖는 속성값을 얻습니다.

Enumeration getAttributeNames(): 이 요청이 갖는 속성들의 이름에 대한 Enumeration 객체를 얻습니다.

void setAttribute(String key, Object o): 주어진 이름의 속성을 설정합니다.

void remvoeAttribute(String key): 주어진 이름의 속성을 제거합니다.

String getProtocol(): "HTTP/1.1" 과 같은 형식으로 프로토콜 및 major/minor 버전을 얻습니다.

String getRemoteAddr(): 요청한 클라이언트의 IP(Internet Protocol) 주소를 얻습니다.

String getRemoteHost(): 요청한 클라이언트의 호스트 이름을 얻습니다.

String getScheme(): http, https, 또는 ftp 등과 같은 요청을 위해 사용된 방법의 이름을 얻습니다.

String getServerName(): 요청을 받은 서버의 이름을 얻습니다.

int getServerPort(): 요청을 받은 포트 번호를 얻습니다.

 

ServletRequest의 멤버메서드

클라이언트가 전송한 정보추출

String getCharacterEncoding(): 이 요청에 사용된 문자 인코딩을 얻습니다.

int getContentLength(): 이 요청에 포함되어 있는 데이터의 길이를 구하며, 만약 길이를 알 수 없는 경우에는 ?1이 리턴됩니다.

String getContentType(): 요청에 포함되어 있는 내용에 대한 MIME 타입 또는 모를 경우에는 null을 얻습니다.

Enumeration getParameterNames(): 매개변수들의 이름에 대한 Enumeration 객체를 얻습니다.

String getParameter(String name): 주어진 이름의 매개변수가 갖는 값을 얻습니다.

String[] getParameterValues(String name): 주어진 이름으로 전달된 매개변수가 갖는 모든 값을 문자열 배열로 얻습니다. 매개변수가 다중 선택이 가능한 리스트(list) 또는 선택박스(choicebox)의 값이라면, 여러 개의 값이 하나의 이름으로 전달될 수 있습니다.

BufferedReader getReader(): 요청 바디로부터 문자 인코딩에 따라 텍스트를 읽어들이기 위한 BufferedReader 객체를 얻습니다.

ServletInputStream getInputStream(): 이 요청의 바디로부터 바이너리 데이터를 읽어들이기 위해, 한 번에 한 라인씩 읽을 수 있는 ServletInputStream 객체를 얻습니다.

 

이와 같은 메서드들은 HTTP 프로토콜에 맞추어져 있는 것이 아니라 일반적인 네트웍 통신기반에 의해서 사용되는 메서드입니다. 그래서 HTTP프로토콜에 존재하는 Session과 Cookie같은 정보를 추출하는 작업은 할 수 없습니다. 그렇기 때문에 HTTP프로토콜을 지원하는 HttpServletRequest에서는 당연히 HTTP프로토콜에 사용되는 대부분의 기능을 포함하고 있습니다. HTTP프로토콜상에서 사용되는 기능별로 분류해 보면 다음과 같습니다.

 

HttpServletRequest의 기능별 분류

n        request객체의 요청 파라미터

n        request객체의 HTTP 헤더

n        request객체의 세션 데이터

n        request객체의 쿠키

n        request객체의 요청에 사용된 URL/URI

 

이러한 분류에 따라 메서드를 나누어 보면 다음과 같습니다.

 

request객체의 요청 파라미터

public String getParameter(String name) : 주어진 이름의 매개변수가 갖는 값을 얻습니다. 지정된 이름의 파라미터가 존재하지 않을 경우 null을 반환합니다.

public Enumeration getParameterNames(): 매개변수들의 이름에 대한 Enumeration으로 반환합니다.

public String[] getParameterValues(String name) : 주어진 이름으로 전달된 매개변수가 갖는 모든 값을 문자열 배열로 얻습니다. 매개변수가 다중 선택이 가능한 리스트(list) 또는 선택박스(choicebox)의 값이라면, 여러 개의 값이 하나의 이름으로 전달될 수 있지만 매개변수가 하나의 값을 갖는 경우라면 getParameter(String name)를 사용하는 것이 낫습니다.

 

 

request객체의 HTTP 헤더

public String getHeader(String headerName) : HTTP 요청헤더에 지정된 headerName의 값을 문자열로 반환합니다. 만약 HTTP 요청헤더에 headerName의 값이 존재하지 않는다면 null을 반환합니다.

public Enumeration getHeaderNames() : HTTP 요청헤더에 포함된 모든 헤더의 이름을 Enumeration으로 반환합니다.

public Enumeration getHeaders (String headerName) : HTTP 요청헤더에 포함된 headerName의 모든 값을 Enumeration으로 반환합니다.

public int getIntHeader (String headerName) : HTTP 요청헤더에 포함된 headerName의 값을 int로 반환합니다. 지정된 headerName의 값을 int로 변환 할 수 없는 경우 NumberFormatException이 발생하고 headerName 헤더가 HTTP 요청헤더에 존재하지 않을 경우에는 –1을 반환합니다.

public long getIDateHeader (String headerName) : HTTP 요청헤더에 포함된 headerName의 값을 millisecond 변환하여 long으로 반환합니다. 지정된 headerName의 값을 int로 변환 할 수 없는 경우 IllegalArgumentException이 발생하고 headerName 헤더가 HTTP 요청헤더에 존재하지 않을 경우에는 –1을 반환합니다.

 

request객체의 세션 데이터 

public HttpSession getSession() : 요청을 시도한 클라이언트에 지정된 HttpSession 객체를 얻습니다.  이전에 생성된 HttpSession 객체가 없었다면 새로운 세션 객체를 생성합니다. 

public HttpSession getSession(boolean create) : 요청을 시도한 클라이언트에 지정된 HttpSession 객체를 얻습니다. create가 false로 지정된 경우 해당 클라이언트에 대해 생성된 HttpSession 객체가 없는 경우 null을 반환합니다. create가 treu로 지정된 경우 이미 생성된 HttpSession 객체를 반환하고 만약 해당 클라이언트에 생성된 HttpSession 객체가 없는 경우 새로운 세션 객체를 생성하여 리턴합니다.

public String getRequestedSessionId(): 요청을 시도한 클라이언트의 세션 id를 문자열로 반환합니다.

public String isRequestedSessionId() : 요청을 시도한 클라이언트의 세션 id가 유효하면 true 아니면 false를 리턴합니다.

isRequestedSessionIdFromCookie() : 요청을 시도한 클라이언트의 세션 id가 쿠키로 전달된 경우 true 아니면 false를 리턴합니다.

isRequestedSessionIdFromURL() : 요청을 시도한 클라이언트의 세션 id가 URL에 포함된 경우 true 아니면 false를 리턴합니다.

 

request객체의 쿠키 

public Cookie[] getCookies() : 클라이언트의 요청에 포함된 쿠키를 Cookie배열로 리턴합니다.

 

request객체의 요청에 사용된 URL/URI 

public String getRequestURI() : 요청에 사용된 URL로부터 URI부분을 문자열로 리턴합니다.  

public String getQueryString():요청에 사용된 쿼리 문자열을 문자열로 리턴합니다..

public String getMethod() : 요청에 사용된 요청방식을 문자열로 리턴합니다.







<delete id="deleteMyInfo">
{call
declare
begin
DELETE FROM TABLE1 WHERE TABLE1 IN (SELECT TABLE1_NUM FROM TABLE1 WHERE MEM_ID = #{memId});
DELETE FROM TABLE2 WHERE TABLE2 IN (SELECT TABLE2_NUM FROM TABLE2 WHERE MEM_ID = #{memId});
DELETE FROM TABLE3 WHERE MEM_ID = #{memId};
end

</delete>

the source of news - https://dzone.com/articles/web-application-development


Codenvy Git Repository


Codenvy Git Repository Initialization

Click Git > Git URL (Read-only)

Codenvy Git URL

Copy the URL to your repository in the appeared window.

Codenvy Repository URL

Deploy Java application

1. Go back to the Jelastic dashboard and click Add project.

Add Project to Jelastic

2. In the appeared window enter the name of your Jelastic project and paste the link to your Git repository that you copied from the Codenvy dashboard. After that, type the name of the branch, login and password (if it’s a private Git repository) and choose the environment for further project deployment.

The Jelastic system can easily check if you have made any commits to your Git repository and build and deploy your Java project automatically based on these commits. To enable this feature, tick the Check and Auto-deploy Updates check-box and specify the time period for verification in minutes.

Jelastic Add Git Project

3. In a few seconds your Jelastic project will appear on the dashboard.

Jelastic Maven Project

4. Click the Build and Deploy button to get your project up and running right in the Cloud.

Build and Deploy Jelastic Project

5. In a few minutes open your Java application in a web browser.

Open App in a Browser

As you can see, your Java application developed with Codenvy IDE was successfully deployed to the Cloud.

Codenvy HelloWorld


'IDE > Eclipse' 카테고리의 다른 글

[Eclipse / Tomcat] Tomcat Server 추가 시 Server name disable 문제  (0) 2016.09.09
[Theme] How to Eclipse theme MoonRise Change  (0) 2016.07.13
[IDE] Eclipse 단축키  (0) 2015.12.19
[eclipse] STS 설정  (0) 2015.09.03
[주석] JavaDoc 기본  (0) 2014.02.13

개발자들이 직접 작성한 오픈소스 면접 질문들을 모아놓은 github 프로젝트 



#어썸인터뷰

https://github.com/MaximAbramchuck/awesome-interviews

 

#어썸인터뷰 자바개발자

https://github.com/MaximAbramchuck/awesome-interviews#java





SELECT MAX (DECODE (activity_item, 110, activity_item, 0) ) t1,

         MAX (DECODE (activity_item, 210, activity_item, 0) ) t2,

         MAX (DECODE (activity_item, 220, activity_item, 0) ) t3,

         MAX (DECODE (activity_item, 230, activity_item, 0) ) t4

    FROM TB_EV_ACTIVITY

GROUP BY mem_id, idea_num


해당 mem_id 참여자와, idea_num 아이디어로 중복을 제거한뒤

decode 함수로 해당 테이블의 activity_item이 110일때만 뽑고 나머진 0 으로 나오기때문에

그중 최고치인(max) 110을 제외한 나머지 행을 중복 거른다


결국 한 사람 과 한 아이디어에 관해 (group by) 110, 210 혹은 210, 220, 230 처럼 

열 데이터를 행으로 뿌려준다





아래 출처 : http://www.gurubee.net/lecture/1028


DECODE함수는 집계함수와 함께 통계 데이터를 추출할 때 많이 사용한다. 아래는 부서별로 급여합계를 조회하는 예이다

1
2
3
4
5
6
7
8
9
10
11
12
13
-- 부서별로 급여 합계를 출력한다.
SELECT deptno, NVL(SUM(DECODE(deptno, 10, sal)),0) deptno10,
               NVL(SUM(DECODE(deptno, 20, sal)),0) deptno20,
               NVL(SUM(DECODE(deptno, 30, sal)),0) deptno30,
               NVL(SUM(DECODE(deptno, 40, sal)),0) deptno40
  FROM emp
 GROUP BY deptno;
 
DEPTNO   DEPTNO10   DEPTNO20   DEPTNO30   DEPTNO40
------- --------- --------- ---------- ----------
     30         0         0       9400          0
     20         0     10875          0          0
     10      8750         0          0          0

아래 부서별 급여합계 예를 보면 일반적인 집계함수를 사용할 때는 급여 합계가 행으로 조회가 되지만, DECODE와 MAX함수를 사용하면 열로 값을 표시할 수 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- 부서별로 급여 합계를 행으로 출력한다.
SELECT d.deptno, NVL(SUM(e.sal),0) sal
  FROM emp e, dept d
 WHERE e.deptno(+) = d.deptno
 GROUP BY d.deptno;
 
DEPTNO        SAL
-------- ----------
      10       8750
      20      10875
      30       9400
      40          0
 
 
 
-- 부서별로 급여 합계를  열로 출력한다.
SELECT MAX(NVL(SUM(DECODE(deptno, 10, sal)),0)) deptno10,
       MAX(NVL(SUM(DECODE(deptno, 20, sal)),0)) deptno20,
       MAX(NVL(SUM(DECODE(deptno, 30, sal)),0)) deptno30,
       MAX(NVL(SUM(DECODE(deptno, 40, sal)),0)) deptno40
  FROM emp
 GROUP BY deptno;
 
DEPTNO10   DEPTNO20   DEPTNO30   DEPTNO40
--------- ---------- ---------- ----------
    8750      10875       9400          0

- Eclipse 자주 쓰는 단축키 -

 

----- 실행 -----

Ctrl + F11 : 바로 전에 실행했던 클래스 실행

 

----- 소스 네비게이션 -----

Ctrl + 마우스커서(혹은 F3) : 클래스나 메소드 혹은 멤버를 상세하게 검색하고자 할때

Alt + LeftAlt + Right : 이후이전

Ctrl + O : 해당 소스의 메소드 리스트를 확인하려 할때

F4 : 클래스명을 선택하고 누르면 해당 클래스의 Hierarchy 를 볼 수 있다.


Alt + <-(->) : 이전(다음) 작업 화면

 

----- 문자열 찾기 -----

Ctrl + K : 찾고자 하는 문자열을 블럭으로 설정한 후 키를 누른다.

Ctrl + Shift + K : 역으로 찾고자 하는 문자열을 찾아감.

Ctrl + J : 입력하면서 찾을 수 있음.

Ctrl + Shift + J : 입력하면서 거꾸로 찾아갈 수 있음.

Ctrl + F : 기본적으로 찾기

 

----- 소스 편집 -----

Ctrl + Space : 입력 보조장치(Content Assistance) 강제 호출 => 입력하는 도중엔 언제라도 강제 호출 가능하다.

F2 : 컴파일 에러의 빨간줄에 커서를 갖져다가 이 키를 누르면 에러의 원인에 대한 힌트를 제공한다.

Ctrl + L : 원하는 소스 라인으로 이동

   로컬 히스토리 기능을 이용하면 이전에 편집했던 내용으로 변환이 가능하다.

Ctrl + Shift + Space : 메소드의 가로안에 커서를 놓고 이 키를 누르면 파라미터 타입 힌트를 볼 수 있다.

Ctrl + D : 한줄 삭제

Ctrl + W : 파일 닫기

Ctrl + I : 들여쓰기 자동 수정

Ctrl + Shift + / : 블록 주석(/* */)

Ctrl + Shift + \ : 블록 주석 제거

Ctrl + / : 여러줄이 한꺼번에 주석처리됨주석 해제하려면 반대로 하면 된다.

Alt + Up(Down) : 위(아래)줄과 바꾸기

Alt + Shift + 방향키 : 블록 선택하기

Ctrl + Shift + Space : 메소드의 파라메터 목록 보기

Ctrl + Shift + O : 자동으로 import 하기

Ctrl + Shift + F4 : 열린 파일 모두 닫기

Ctrl + M : 전체화면 토글

Ctrl + Alt + Up(Down) : 한줄(블럭복사

Ctrl + , or . : 다음 annotation(에러워닝북마크 가능)으로 점프

Ctrl + 1 : 퀵 픽스

F3 : 선언된 변수로 이동, 메소드 정의부로 이동

Ctrl + T : 하이어라키 �b업 창 띄우기(인터페이스 구현 클래스간 이동시 편리)

Ctrl + O : 메소드나 필드 이동하기

Ctrl + F6 : 창간 전환, UltraEdit  Editplus  Ctrl + Tab 과 같은 기능

 

----- 템플릿 사용 -----

sysout 입력한 후 Ctrl + Space 하면 System.out.println(); 으로 바뀐다.

try 입력한 후 Ctrl + Space 하면 try-catch 문이 완성된다.

for 입력한 후 Ctrl + Space 하면 여러가지 for 문을 완성할 수 있다.

템플릿을 수정하거나 추가하려면 환경설정/자바/편집기/템플릿 에서 할 수 있다.

 

----- 메소드 쉽게 생성하기 -----

클래스의 멤버를 일단 먼저 생성한다.

override 메소드를 구현하려면, 소스->메소드대체/구현 에서 해당 메소드를 체크한다.

기타 클래스의 멤버가 클래스의 오브젝트라면, 소스->위임메소드 생성에서 메소드를 선택한다.

 

----- organize import -----

자바파일을 여러개 선택한 후 소스->가져오기 체계화 해주면 모두 적용된다.

 

----- 소스 코드 형식 및 공통 주석 설정 -----

환경설정 -> 자바 -> 코드 스타일 -> 코드 포멧터 -> 가져오기 -> 프로파일.xml 을 불러다가 쓰면 된다.

또한 다수의 자바파일에 프로파일을 적용하려면 패키지 탐색기에서 패키지를 선택한 후 소스 -> 형식화를 선택하면 된다.

환경설정 -> 자바 -> 코드 스타일 -> 코드 템플리트 -> 가져오기 -> 템플리트.xml 을 불러다가 쓰면 된다.

 

----- 에디터 변환 -----

에디터가 여러 파일을 열어서 작업중일때 Ctrl + F6 키를 누르면 여러파일명이 나오고 F6키를 계속 누르면 아래로

Ctrl + Shift + F6 키를 누르면 위로 커서가 움직인다.

Ctrl + F7 : 뷰간 전환

Ctrl + F8 : 퍼스펙티브간 전환

F12 : 에디터로 포커스 위치

 

 

 

 

 

이클립스 자주쓰는 단축키 -

 

Ctrl + / : 주석 처리 - 한 라인/블록에 대해 주석 처리 (추가 및 제거)

Ctrl + L : 특정 라인으로 이동

Ctrl + F6 : Editor 창간의 이동

Ctrl + F7 : View 이동 메뉴

Ctrl + F8 : Prespectives 이동 메뉴

Ctrl + D : 한라인 삭제 - 커서가 위치한 라인 전체를 삭제 한다.

Ctrl + J : Incremental find 이클립스 하단 상태 표시줄에 Incremental find 라고 표시되어 한 글자자씩 누를 때 마다 코드내의 일치하는 문자열로 이동 , 다시 Ctrl + J 를 누르면 그 문자열과 일치 하는 부분을 위/아래 방향키로 탐색이 가능하다.

Ctrl + N : 새로운 파일 / 프로젝트 생성

Ctrl + 1 (빠른교정) - 문 맥에 맞게 소스 교정을 도와 준다변수를 선언하지 않고 썼을경우 빨간색 에러 표시되는데 이 단축키를 적용하면 변수에 맞는 선언이 추가 되도록 메뉴가 나타난다.

Ctrl + 0 : 클래스 구조를 트리로 보기

Ctrl + Space :  Cotent Assist - 소스 구문에서 사용 가능한 메소드멤버들의 리스트 메뉴를 보여준다.

Ctrl + PageUp , Ctrl + PageDown : Edit 창 좌우 이동 - Edit 창이 여러개 띄워져 있을경우 Edit 창간의 이동 한다.

Ctrl + Shift + Down : 클래스 내에서 다음 멤버로 이동

Ctrl + Shift + M : 해당 객체의 Import 문을 자동 생성 - import 추가 할 객체에 커서를 위치 시키고 단축키를 누르면 자동적으로 import 문이 생성

Ctrl + Shift + O : import 문을 자동 생성 - 전체 소스 구문에서 import 안된 클래스의 import 문을 생성해 준다.

Ctrl + Shift + G : 해당 메서드 / 필드를 쓰이는 곳을 표시 - View 영역에 Search 탭에 해당 메서드 / 필드를 사용하는 클래스를 표시 해준다.

Alt + Shift + R : Refactoring (이름변경) - Refactoing 으로 전체 소스에서 이름변경에 의한 참조 정보를 변경해 준다.

F3 선언 위치로 이동

F11 : 디버깅 시작

F8 : 디버깅 계속

F6 : 디버깅 한줄씩 실행(step over)

F5 : 디버깅 한줄씩 실행 함수 내부로 들어감 (step into)

F12 : Editor 창으로 이동 (Debugging 등 자동적으로 포커스가 이동 됐을경우 편리)

Alt + Up , Alt + Down : 줄 바꿈 - 해당 라인을 위 / 아래로 이동 시킨다.

Alt + Shift + S : Source Menu - 소스메뉴 (Import 추가 , Comment 추가 , 각종 Generator 메뉴가 나타난다.

Alt + Shift + Up : 블록설정 - 소스 코드를 블록 단위로 설정해 준다.

Alt + Shift + Down : 블록해제 - 소스 코드를 블록 단위로 해제한다.

Alt + Shift + J : 주석 생성 - 해당 메서드/클래스에 대한 주석을 템플릿을 생성해 준다.

sysout + (Ctrl + Space) : System.out.println() 문장 삽입 - 코드 템플릿을 이용해서 소스 구문을 추가

(Windows -> Preferences -> JAVA -> Editor -> Templates 에서 자주 쓰는 소스 구문을 추가시키면 <템플릿 이름> + (Ctrl + Space) 로 소스 문장을 완성 시킬 수 있다.)

Alt + Shift + Z : Surround With 메뉴 - try / catch 문이나 for , do , while 등을 해당 블록에 감싸주는 메뉴가 나타난다.

Ctrl + Shift + F : 코드 포맷팅 - 코드 내용을 문법 템플릿에 맞게 포맷팅(들여쓰기해준다.

Ctrl + Alt + Down한줄 복사후 아래에 복사 넣기 - Copy&Paste 대체하는 단축키커서가 위치한 라인을 복사해 밑줄에 생성해 준다.

Ctrl + Shift +X : 대문자로 변환

Ctrl + Shift + Y : 소문자로 변환

Ctrl + Shift + L : 모든 단축키의 내용을 표시해준다.

Ctrl + Shift + B : 현재 커서 라인에 Break point 설정

Ctrl + Shift + T : 클래스 찾기



출처 : http://egloos.zum.com/littletrue/v/3987863

Spring Web MVC offers seamless integration with different view technologies, including Excel document view. When configured properly, a Spring’s view resolver can generate an Excel document from model data and send it to the client for downloading or opening by a spreadsheet program like Microsoft Excel. For working with Excel view, Spring supports two popular libraries such as Apache POI and JExcelApi (Both are free and open source). This tutorial is going to help you in understanding how to configure Spring MVC to work with these libraries in order to deliver dynamic content in form of Excel document to the users, by developing a sample Spring MVC application that allows the users to download an Excel document generated on the fly:

Spring MVC Excel View Demo with Apache POI

Clicking on the download link will prompt the users for downloading/opening the document which looks like the following screenshot in Microsoft Excel program:

Open downloaded Excel document in MS Excel

About Apache POI

Apache POI is a set of pure Java libraries for reading and writing Microsoft Office documents such as Word, Excel, Powerpoint, Outlook, etc. Click the following link to download its latest distribution (which is Apache POI 3.9, as of this writing):

Apache POI Download

The distribution comes with several jar files, but the only the poi-VERSION.jar file is required for typical usage of generating Excel documents (if you want to generate Excel XML format such as *.xlsx files, use the poi-ooxml-VERSION.jarfile).

To generate an Excel document using Apache POI within Spring, we need to create a view class that extends from theAbstractExcelView class and override its method buildExcelDocument(). Then using Apache POI’s Excel API to generate the excel document.

About JExcelApi

JExcelApi is a Java library that is dedicated for reading, writing and modifying Excel spreadsheets. It supports Excel 2003 file format and older versions. You can download JExcelApi from the following link:

               JExcelApi DownloadTo work with JExcelApi, you need to add its only jar file: jxl.jar - to your project’s classpath. And Spring provides an abstract class called AbstractJExcelView which should be extended to generate an Excel document using JExcelApi, similarly to the case of Apache POI.

This tutorial will use Apache POI for the sample application. However, you can also download a JExcelApi version of the project in the Attachments section.

In Eclipse IDE, create a Dynamic Web Project called SpringMvcExcelViewDemo. We will end up with the following project structure:

Spring MVC Excel View Demo Eclipse project structure

The jar files used are:

      • spring-beans-3.2.3.RELEASE.jar
      • spring-context-3.2.3.RELEASE.jar
      • spring-context-support-3.2.3.RELEASE.jar
      • spring-core-3.2.3.RELEASE.jar
      • spring-expression-3.2.3.RELEASE.jar
      • spring-web-3.2.3.RELEASE.jar
      • spring-webmvc-3.2.3.RELEASE.jar
      • commons-logging-1.1.1.jar
    • Apache POI:
      • poi-3.9-20121203.jar
 

This book: Getting started with Spring Framework  helps you master all major concepts like Spring core modules, dependency injection, Spring AOP, annotation-driven development, and more.

 

1. Creating Model Class

We will generate an Excel document that contains a list of Java books, so create the following model class (Book.java):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package net.codejava.spring;
 
public class Book {
    private String title;
    private String author;
    private String isbn;
    private String publishedDate;
    private float price;
 
    public Book(String title, String author, String isbn, String publishedDate,
            float price) {
        this.title = title;
        this.author = author;
        this.isbn = isbn;
        this.publishedDate = publishedDate;
        this.price = price;
    }
 
    // getters and setters
 
}


2. Coding Entry JSP Page

We need to create a JSP page that displays a hyperlink on which the users will click to download the Excel file. Create a folder called jsp inside WEB-INF directory and create a JSP file called home.jsp under WEB-INF\jsp with the following content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Spring MVC Excel View Demo (Apache POI)</title>
</head>
<body>
    <div align="center">
        <h1>Spring MVC Excel View Demo (Apache POI)</h1>
        <h3><a href="/downloadExcel">Download Excel Document</a></h3>
    </div>
</body>
</html>
The hyperlink Download Excel Document points to a relative URL downloadExcel which will be handled by a Spring controller class as described below.



3. Coding Spring Controller

Create a Spring controller class called MainController with the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package net.codejava.spring;
 
import java.util.ArrayList;
import java.util.List;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
 
/**
 * A Spring controller that allows the users to download an Excel document
 * generated by the Apache POI library.
 *
 * @author www.codejava.net
 *
 */
@Controller
public class MainController {
 
    /**
     * Handle request to the default page
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String viewHome() {
        return "home";
    }
 
    /**
     * Handle request to download an Excel document
     */
    @RequestMapping(value = "/downloadExcel", method = RequestMethod.GET)
    public ModelAndView downloadExcel() {
        // create some sample data
        List<Book> listBooks = new ArrayList<Book>();
        listBooks.add(new Book("Effective Java""Joshua Bloch""0321356683",
                "May 28, 2008"38.11F));
        listBooks.add(new Book("Head First Java""Kathy Sierra & Bert Bates",
                "0596009208""February 9, 2005"30.80F));
        listBooks.add(new Book("Java Generics and Collections",
                "Philip Wadler""0596527756""Oct 24, 2006"29.52F));
        listBooks.add(new Book("Thinking in Java""Bruce Eckel""0596527756",
                "February 20, 2006"43.97F));
        listBooks.add(new Book("Spring in Action""Craig Walls""1935182358",
                "June 29, 2011"31.98F));
 
        // return a view which will be resolved by an excel view resolver
        return new ModelAndView("excelView""listBooks", listBooks);
    }
}
As we can see, this controller class implements two request handling methods:

    • viewHome(): this method simply returns a logical view name “home” which will be resolved to the home.jsp page (We will configure view resolver for JSP later).
    • downloadExcel(): this method creates some dummy data, e.g. creating some books and add them to a list. Finally this method returns a logical view name “excelView” and passes the list of books as the name “listBooks” to the model. We will configure an Excel view class for this view later.  

This book: Spring in Action  helps you learn the latest features, tools, and practices including Spring MVC, REST, Security, Web Flow, and more.


4. Coding Excel View Class

To generate an Excel document from the model data passed by the controller, create a subclass of the AbstractExcelViewclass as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package net.codejava.spring;
 
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.springframework.web.servlet.view.document.AbstractExcelView;
 
/**
 * This class builds an Excel spreadsheet document using Apache POI library.
 * @author www.codejava.net
 *
 */
public class ExcelBuilder extends AbstractExcelView {
 
    @Override
    protected void buildExcelDocument(Map<String, Object> model,
            HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        // get data model which is passed by the Spring container
        List<Book> listBooks = (List<Book>) model.get("listBooks");
         
        // create a new Excel sheet
        HSSFSheet sheet = workbook.createSheet("Java Books");
        sheet.setDefaultColumnWidth(30);
         
        // create style for header cells
        CellStyle style = workbook.createCellStyle();
        Font font = workbook.createFont();
        font.setFontName("Arial");
        style.setFillForegroundColor(HSSFColor.BLUE.index);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        font.setColor(HSSFColor.WHITE.index);
        style.setFont(font);
         
        // create header row
        HSSFRow header = sheet.createRow(0);
         
        header.createCell(0).setCellValue("Book Title");
        header.getCell(0).setCellStyle(style);
         
        header.createCell(1).setCellValue("Author");
        header.getCell(1).setCellStyle(style);
         
        header.createCell(2).setCellValue("ISBN");
        header.getCell(2).setCellStyle(style);
         
        header.createCell(3).setCellValue("Published Date");
        header.getCell(3).setCellStyle(style);
         
        header.createCell(4).setCellValue("Price");
        header.getCell(4).setCellStyle(style);
         
        // create data rows
        int rowCount = 1;
         
        for (Book aBook : listBooks) {
            HSSFRow aRow = sheet.createRow(rowCount++);
            aRow.createCell(0).setCellValue(aBook.getTitle());
            aRow.createCell(1).setCellValue(aBook.getAuthor());
            aRow.createCell(2).setCellValue(aBook.getIsbn());
            aRow.createCell(3).setCellValue(aBook.getPublishedDate());
            aRow.createCell(4).setCellValue(aBook.getPrice());
        }
    }
 
}
 

For working with JExcelApi, make the class extends the AbstractJExcelView class like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package net.codejava.spring;
 
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
 
import org.springframework.web.servlet.view.document.AbstractJExcelView;
 
/**
 * This class builds an Excel spreadsheet document using JExcelApi library.
 * @author www.codejava.net
 *
 */
public class ExcelBuilder extends AbstractJExcelView {
 
    @Override
    protected void buildExcelDocument(Map<String, Object> model,
            WritableWorkbook workbook, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
         
        // get data model which is passed by the Spring container
        List<Book> listBooks = (List<Book>) model.get("listBooks");
         
        // create a new Excel sheet
        WritableSheet sheet = workbook.createSheet("Java Books"0);
         
        // create header row
        sheet.addCell(new Label(00"Book Title"));
        sheet.addCell(new Label(10"Author"));
        sheet.addCell(new Label(20"ISBN"));
        sheet.addCell(new Label(30"Published Date"));
        sheet.addCell(new Label(40"Price"));
         
        // create data rows
        int rowCount = 1;
         
        for (Book aBook : listBooks) {
            sheet.addCell(new Label(0, rowCount, aBook.getTitle()));
            sheet.addCell(new Label(1, rowCount, aBook.getAuthor()));
            sheet.addCell(new Label(2, rowCount, aBook.getIsbn()));
            sheet.addCell(new Label(3, rowCount, aBook.getPublishedDate()));
            sheet.addCell(new jxl.write.Number(4, rowCount, aBook.getPrice()));
             
            rowCount++;
        }
    }
}
The above code is self-explanatory. As you can see, there are some differences between the Apache POI API and the JExcelApi.

 

See more: How to Write Excel Files in Java using Apache POI

 

This book: Spring Integration in Action help you learn more about enterprise integration and messaging using the Spring Integration framework.


5. Configuring Excel View Class

Next, we need to tell Spring to use the above ExcelBuilder class as view class for the view name “excelView” returned from the controller’s downloadExcel() method. There are two ways to do this by creating either a .properties file or an XML file.

Using views.properties file:

Create a .properties file called views.properties under the project’s classpath (which is under src directory in the Eclipse project), with the following line:

1
excelView.(class)=net.codejava.spring.ExcelBuilder
That tells the Spring’s view resolver to use the net.codejava.spring.ExcelBuilder class to process output for the view name “excelView”.

 

Using views.xml file:

An alternative to the views.properties file is to use XML version. Create views.xml file under WEB-INF directory with the following content:

1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
     
    <bean id="excelView" class="net.codejava.spring.ExcelBuilder" />
     
</beans>
Note that the bean’s ID attribute must correspond to the view name “excelView”.

 


6. Writing Spring Configuration File

Create a Spring configuration file named spring-mvc.xml under WEB-INF directory. In case you are usingviews.properties file, put the following content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
    <context:component-scan base-package="net.codejava.spring" />
 
   <bean id="viewResolver1" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
        <property name="order" value="1"/>
        <property name="basename" value="views"/>
    </bean>
     
    <bean id="viewResolver2"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="order" value="2"/>
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
     
</beans>
As seen in the above configuration, there are two view resolvers used here:

    • ResourceBundleViewResolver: to resolve view names specified in the views.properties file.
    • InternalResourceViewResolver: to resolve view names to JSP pages.
The order property does matter here, in which the first resolver has higher priority than the second one.

 

In case the views.xml is used, configure Spring as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
    <context:component-scan base-package="net.codejava.spring" />
 
   <bean id="viewResolver1" class="org.springframework.web.servlet.view.XmlViewResolver">
        <property name="order" value="1"/>
        <property name="location" value="/WEB-INF/views.xml"/>
    </bean>
     
    <bean id="viewResolver2"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="order" value="2"/>
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
 
     
</beans>
 

Discover how to write efficient batch applications with Spring Batch in Action


7. Configuring Spring MVC in web.xml

The final step is to configure Spring MVC in the web deployment descriptor file as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
     
    <display-name>SpringMvcExcelViewDemo</display-name>
     
    <servlet>
        <servlet-name>SpringController</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring-mvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>SpringController</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping
</web-app>


8. Testing the application

Type the following URL into browser to access the application we’ve built:

http://localhost:8080/SpringMvcExcelViewDemo/

The default page (home.jsp) gets displayed (in FireFox):

Test Spring MVC Excel View Demo in Firefox

Click on the “Download Excel Document” link, the browser will ask for opening or saving the file:

Opening downloadExcel dialog

Select Open with (Microsoft Office Excel), the document gets opened in Excel as follows:

Open downloaded Excel document in MS Excel

 

Download Eclipse project for this application in the Attachments section below





출처 : http://www.codejava.net/frameworks/spring/spring-mvc-with-excel-view-example-apache-poi-and-jexcelapi


# sudo yum -y install httpd

# sudo yum -y install mysql mysql-server

# sudo yum -y install php php-mysql



#sudo service mysqld start

#mysql -u root -p mysql 



mysql> update user set password=password('원하는 비밀번호') where user='root';

mysql> flush privileges;


mysql> create database wordpress;

mysql> INSERT INTO mysql.user (host,user,password, ssl_cipher, x509_issuer, x509_subject) VALUES ('%','wp',password('wp'),'','','');

mysql> flush privileges;

mysql> grant all privileges on wordpress.* to jh@% identified by 'qwer' with grant option;


mysql> quit;


* netstat 에 대하여

열려져 있는 포트 및 서비스 중인 프로세스들의 상태 정보와 네트워크 연결상태를 보기위한 명령어


-a 모든연결 및 수신 대기 포트 표시

-c 현재 실행 명령을 매 초마다 실행

-l Listen 하고 있는 포트를 보여줌

-t tcp로 연결된 포트를 보여줌

-u udp로 연결된 포트를 보여줌

-n 주소나 포트 형식을 숫자로 표현

-p 해당 프로세스를 사용하고 있는 프로그램 이름을 보여줌

-r 라우팅 테이블을 보여줌


state


LISTEN 요청을 받을 수 있도록 연결 요구를 기다리는 상태. 즉, 포트가 열려있음

ESTABLISHED 서로 연결 되어 있는 상태 

SVN_SENT      클라이언트가 서버에게 SYN패킷을 보낸 후 연결을 요청한 상태

SVN_RECV      서버가 클라이언트의 SYN패킷으로 서비스를 요청 받은 후에 이에대한 응답으로 SYN/ACK패킷을 보내고 클라이언트에게 ACK를                       받길 대기하는 상태

TIME_WAIT      연결은 종료되었으나 대기 상태

CLOSE_WAIT 원격의 연결 요청을 받고 연결이 종료되길 기다리는 있는 상태

LAST_ACK      연결이 종료되엇고 승인을 기다리는 상태

CLOSED 완전히 연결이 종료된 상태


관련 url     ::    http://najuung.tistory.com/41



#sudo netstat -lntp | grep mysql  // mysqld ::: 3306 이라는 문장이 있으면 제대로 동작중임


#sudo service httpd start

#sudo netstat -lntp | grep httpd    // httpd ::: 80 포트 있으면 제대로 동작중임


#sudo wget https://ko.wordpress.org/wordpress-4.2.4-ko_KR.zip / tar 아무거나 받아도 상관없다


#unzip ./word ... 4.2.4


현재 ~ 폴더아래에 ./wordpress 가 생성된다

압축을 풀어둔 워드프레스 파일을 /wordpress 디렉토리로 복사한 후 설정파일을 생성한다.

# cp -a ~/wordpress/* /wordpress/

# cd /wordpress

# cp wp-config-samples.php wp-config.php

/wordpress 디렉토리 안에 만들어진 wp-config.php를 열어 아래와 같이 수정한다.

사용자 지정 2

여기서 wordpress에는 앞에서 생성한 DB 이름, wp에는 DB 사용자 이름, dbpassword 부분에는 DB 사용자의 암호를 입력한다.

다음의 명령어를 수행하여 /wordpress 디렉토리의 권한을 apache.apache로 변경한다.

# chown -R apache.apache /wordpress

마지막으로 웹서버 설정 파일 /etc/httpd/conf/httpd.conf 파일에서 기본 디렉토리를  /wordpress로 변경한다. 중간 부분의 DocumentRoot 부분을 찾아서 다음 그림과 같이 /wordpress로 변경한다.

13

그리고 바로 아래에 있는 AllowOverride None을 AllowOverride All 로 수정한다.

14

httpd 서비스를 재시작한다.

# service httpd restart

모든 설정이 정상정으로 완료되면 http://ip-address 를 입력하면 다음과 같이 워드프레스 설정화면이 나타난다.

'Server > AWS' 카테고리의 다른 글

[Node.js] AWS install nodejs  (0) 2020.07.31
[AWS] How to Install MariaDB on Ubuntu 18.04  (0) 2020.03.18
[AWS] 웹서비스 세션 처리  (0) 2019.09.11
[Amazon Web Service] EC2 참고  (0) 2014.09.16
[AWS] 관련 서버 셋팅  (0) 2014.02.25

+ Recent posts