본문 바로가기

개발하자/JSP&Servlet

(82)
jQuery BlockUI Plugin http://jquery.malsup.com/block/#demos
annotation aa bb cc dd 1 @WebServlet(initParams={ @WebInitParam(name="aa",value="bb"), @WebInitParam(name="cc",value="dd") } ,loadOnStartup=1) class ServletText extends HttpServlet{ }
Target,Retention xml파일에 FileOutputStream이용하여 내용넣기 import java.lang.annotation.*; import java.lang.reflect.*; import java.io.*; @Target(value=ElementType.METHOD) @Retention(value=RetentionPolicy.RUNTIME) @interface WebServlet{ String urlPatterns(); } class ServletTest{ @WebServlet(urlPatterns="/now") void doGet(){ } } class A{ public static void main(String args[]) throws Exception{ Method m=ServletTest.class.getDeclaredMethod("doGet"); WebServl..
m.getName().startsWith("set") Bean에 자동셋팅 주소창 입력:http://localhost:8090/jsp_test1/a.jsp?id=aa&pw=bb
getDeclaredMethod,getAnnotation import java.lang.annotation.*; import java.lang.reflect.*; @Target(value={ElementType.METHOD,ElementType.TYPE}) @Retention(value=RetentionPolicy.RUNTIME) @interface DD{ int a(); String b() default "bbb"; int[] c() default {600,700}; } @DD(a=100,b="aaa",c={200,300,400}) class B{ @DD(a=500) void d(){ System.out.println("메서드"); } public static void main(String args[]) throws Exception{ Method m=B.c..
원하는 메서드 이름 얻어오기 getDeclaredMethod import java.lang.reflect.*; class A{ void a(){} void b(){} int c(){ return 100; } } class B{ public static void main(String args[]) throws NoSuchMethodException { Class o=A.class; System.out.println(o.getDeclaredMethod("c")); //원하는 메서드 이름 얻어오기 } }
선언되어 있는 모든 메서드 이름 출력하기 import java.lang.reflect.*; class A{ void a(){} void b(){} int c(){ return 100; } } class B{ public static void main(String args[]){ Class o=A.class; Method[] array=o.getDeclaredMethods();//선언되어 있는 모든 메서드 가져오기 for(Method n:array){ System.out.println(n); } } }
어노테이션 만드는 방법 Annotation //어노테이션 만드는 방법 import java.lang.annotation.*; @Target(value={ElementType.METHOD,ElementType.TYPE}) //이 어노테이션을 어디다가 지정하겠냐 @Retention(value=RetentionPolicy.RUNTIME) @interface DD{//어노테이션 이름 int a(); String b() default "bbb";//default값을 줄수 있다. int[] c() default {600,700}; //default값을 줄수 있다. } @DD(a=100,b="aaa",c={200,300,400}) //어노테이션 적용 class B{ @DD(a=500)//여기서도 어노테이션 적용 가능 //위에서 디폴트 값을 줘야 에러안남 vo..