'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 |
[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/
1 2 3 4 5 6 | Random rand 1 = new Random( 123 L); /* [0,20] 범위에 있는 또다른 정수현 난수를 생성한다. */ int n = rand 1 .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 rand 3 = null; try { rand 3 = SecureRandom.getInstance( "SHA1PRNG" ); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } System.out.println( "SecureRandom============================================" ); n = rand 3 .nextInt( 21 ); System.out.println(n); |
1 2 3 4 5 6 7 8 9 | /* Random의 기본 생성자를 이용하면 생성자를 호출 할 때 마다 다른 값을 초기 값으로 가져올 수 있다. */ Random rand 2 = new Random(); System.out.println( "Random2 =================================================" ); for(int i = 0 ; i < 20 ; i++) { /* 난수 생성기의 초깃값을 다시 설정 */ rand 2 = new Random(); n = rand 1 .nextInt( 21 ); System.out.println(n); } |
[Book] 알고리즘 관련 서적 for java (0) | 2016.07.05 |
---|---|
[Java] 문자열 포함여부 확인 - contains, indexOf, matches (0) | 2016.01.12 |
[Request] 호스트 설정 jsp (0) | 2016.01.12 |
URL Encoding 특수문자 코드 (0) | 2015.07.22 |
[Encode] java replaceall 특수문자 (0) | 2015.07.22 |
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로 확장하여 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() : 요청에 사용된 요청방식을 문자열로 리턴합니다. |
[Java] 문자열 포함여부 확인 - contains, indexOf, matches (0) | 2016.01.12 |
---|---|
[random] java.security.SecureRandom (0) | 2016.01.12 |
URL Encoding 특수문자 코드 (0) | 2015.07.22 |
[Encode] java replaceall 특수문자 (0) | 2015.07.22 |
[Date] 날짜 객체 현재 날짜 비교 / DateFormat (0) | 2015.07.08 |
</delete>
[ORM] MyBatis 동적 쿼리 trim (0) | 2018.03.28 |
---|---|
[Procedure] ibatis 호출 (0) | 2015.02.12 |
[Spring] Repository sqlMapClientTemplate 맵핑 (0) | 2014.08.03 |
org.springframework.dao.DataAccessResourceFailureException / RecoverableDataAccessException (0) | 2014.03.25 |
[iBatis] Multi Insert 시 List 형태와 Map 형태 (0) | 2014.02.24 |
the source of news - https://dzone.com/articles/web-application-development
Click Git > Git URL (Read-only)
Copy the URL to your repository in the appeared window.
1. Go back to the Jelastic dashboard and click Add project.
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.
3. In a few seconds your Jelastic project will appear on the dashboard.
4. Click the Build and Deploy button to get your project up and running right in the Cloud.
5. In a few minutes open your Java application in a web browser.
As you can see, your Java application developed with Codenvy IDE was successfully deployed to the Cloud.
[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
[Postman] Tool for sending multipart/form-data request (0) | 2020.11.18 |
---|---|
[Jsp/Servlet] Request, Response, Session (0) | 2018.02.13 |
[encoding] DM 발송시 메일함 링크클릭 포커싱 안될 때 (0) | 2015.06.16 |
[Jsp] 게시판 페이징 (0) | 2014.03.07 |
[HashMap] 다중 리스트 데이터 담기 (0) | 2014.02.18 |
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 |
[ Listener Error ] 64bit toad for oracle ora-12514 (0) | 2016.06.11 |
---|---|
[toad] toad 특문 파라미터 값으로 넣기 (0) | 2016.02.19 |
오라클에 존재하는 Object 관리 Table (0) | 2015.08.25 |
[Trigger] Mutating Error 및 해결책 (0) | 2015.08.24 |
[권한] 오라클 함수 권한 주기 / 함수삭제하기 (0) | 2015.06.25 |
- Eclipse 자주 쓰는 단축키 -
----- 실행 -----
Ctrl + F11 : 바로 전에 실행했던 클래스 실행
----- 소스 네비게이션 -----
Ctrl + 마우스커서(혹은 F3) : 클래스나 메소드 혹은 멤버를 상세하게 검색하고자 할때
Alt + Left, Alt + 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
[Theme] How to Eclipse theme MoonRise Change (0) | 2016.07.13 |
---|---|
[Cloud] 클라우드 ide > Github 연결 (0) | 2016.01.09 |
[eclipse] STS 설정 (0) | 2015.09.03 |
[주석] JavaDoc 기본 (0) | 2014.02.13 |
[Eclipse] default jdk version 셋팅 및 프로젝트 build path 설정 (0) | 2014.02.11 |
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:
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: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 } |
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 > |
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); } } |
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()); } } } |
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( 0 , 0 , "Book Title" )); sheet.addCell( new Label( 1 , 0 , "Author" )); sheet.addCell( new Label( 2 , 0 , "ISBN" )); sheet.addCell( new Label( 3 , 0 , "Published Date" )); sheet.addCell( new Label( 4 , 0 , "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++; } } } |
1 | excelView.(class)=net.codejava.spring.ExcelBuilder |
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 > |
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 > |
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 > |
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 > |
http://localhost:8080/SpringMvcExcelViewDemo/
The default page (home.jsp) gets displayed (in FireFox):[build] spring pom.xml com.microsoft.sqlserver package (0) | 2016.10.25 |
---|---|
[STS] Spring Boot Restful 서버 구축 (Hello World) (0) | 2016.09.07 |
[web.xml] 세션시간, 에러페이지, http-method 설정 (0) | 2015.03.10 |
<스프링과 메이븐을 활용한 실전 프레임워크 설계와 구축> 소스코드 (0) | 2014.12.31 |
[Multi] 다중 삭제 (0) | 2014.11.03 |
# 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를 열어 아래와 같이 수정한다.
여기서 wordpress에는 앞에서 생성한 DB 이름, wp에는 DB 사용자 이름, dbpassword 부분에는 DB 사용자의 암호를 입력한다.
다음의 명령어를 수행하여 /wordpress 디렉토리의 권한을 apache.apache로 변경한다.
# chown -R apache.apache /wordpress
마지막으로 웹서버 설정 파일 /etc/httpd/conf/httpd.conf 파일에서 기본 디렉토리를 /wordpress로 변경한다. 중간 부분의 DocumentRoot 부분을 찾아서 다음 그림과 같이 /wordpress로 변경한다.
그리고 바로 아래에 있는 AllowOverride None을 AllowOverride All 로 수정한다.
httpd 서비스를 재시작한다.
# service httpd restart
모든 설정이 정상정으로 완료되면 http://ip-address 를 입력하면 다음과 같이 워드프레스 설정화면이 나타난다.
[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 |