본문 바로가기

전체 글

(11)
[ spring ] life cycle and scope spring container life cycle spring bean life-cycle 1. implements InitialiaingBean, DisposableBean implements InitialiaingBean 을 하면 아래가 자동으로 override 된다 - afterPropertiesSet 을 call 할수있다. ( ctx.refresh() 할때 call 된다 ) @Override public void afterPropertiesSet() throws Exception { } implements DisposableBean 을 하면 - destory 을 call 할수있다 ( ctx.close() 할때 생성된다 ) @Override public void destroy() throws Exc..
[ ar ] designing recursion - at least 하나의 순환되지 않고 종료되는, base case 가 있어야한다. - 모든 case 는 finally, base case 로 수렴해야 한다. - implicit parameter 를 -> explicit parameter 명시적 로 바꾸어라. sequential search 순차적 : int array 에서 0 ~ n (data 의 갯수) 까지 search 하다가, target 이면 그 위치 i 를 return 한다. static int search(int[] data, int n, int target) { for(int i=0;iend) { return -1; } else if (target==data[begin]) { return begin; } else { return searc..
[ web / jsp ] jsp 문법 JSP 문법 Declaration - : method 선언 or variable 선언 Scriptlet - : programming code Expression - : screen 에 output 할 내용 여기에서 어디에 있는지 위치는 중요하지 않다 id : 이렇게 하면 밑에처럼 바뀌어있다. out.write("id : "); out.print(getId() ); Scriptlet - - scriptlet 안에 선언되는 variable 은 service method 안에 선언되는 variable 이다. - 쪼개서 사용할수있다.
[ web / jsp ] JSP lifecycle JSP 는 servlet 으로 바뀔것이다 tomcat 를 사용할때, tomcat 이 JSP -> servlet 으로 바꾸게 된다. workspace > .metadata > .plugins > org.eclipse.wst.server.core> temp0 > wtpwebapps > firstweb 에 들어가면 sum10 이 있다. D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work > 에서는 servlet 으로 바뀐 코드가 들어있다. 이건 WAS 의 약속이다. 그 안에 들어가서 localhost 에 들어가면 만들었던 web application 이 있는 걸 볼수있다. 계속 들어가보면 이렇게 바뀌어 있다. sum10_jsp.java ..
[ web ] jsp make - 1~ 10 까지 합을 구하는 JSP firstweb 밑에서 JSP 위치는 WebContent 이다. html, css, js 도 이 위치에 만들면 된다. webContent > new > folder folder name: jsp WebContent > new > jsp file file name: sum10.jsp 그러면 이렇게 나온다 여기에 1~10 까지의 합을 구하는 식을 쓴다
9 : Throws throws exception 이 발생했을때 exception 을 호출한쪽에서 처리하도록 던져 throw 해준다. code public.... method() throws exception { .. } public static int divide(int i, int j) throws ArithmeticException{ // throws 무슨예외오류,무슨무슨다른오류,.... int k = i/j; return k; } use it ExceptionExam2 class 을 생성했다. int 두 개를 가져와 divide 해 나온 값을 return하는 method 를 만든다. public class ExceptionExam2 { public static int divide(int i, int j) { int ..
9 : Exception Exception 프로그램실행중 예기치 못한 사건을 예외라고 한다. 예외 상황을 미리 예측하고 처리할 수 있는데, 이렇게 하는 것을 예외 처리라고 한다. why? use it ExceptionExam.java public class ExceptionExam { public static void main(String[] args) { int i = 10; int j = 0; int k = i/j; System.out.println(k); } } >>> 이렇게 0 으로 나눌려고하니 program end Exception in thread "main" java.lang.ArithmeticException: / by zero at ExceptionExam.main(ExceptionExam.java:7) Proc..
8 : inner Class - inner class types static class local class Anonymous class instance class