Java Annotation dzÎö2
Java»ù´¡-ѧϰʹÓÃAnnotation×¢½â¶ÔÏó
×¢½â(Ò²±»³ÆΪԪÊý¾Ý)ΪÎÒÃÇÔÚ´úÂëÖÐÌí¼ÓÐÅÏ¢ÌṩÁËÒ»ÖÖÐÎʽ»¯µÄ·½·¨,ʹÎÒÃÇ¿ÉÒÔÔÚÉÔºóij
¸öʱ¿Ì·Ç³£·½±ãµØʹÓÃÕâЩÊý¾Ý
1-1:»ù±¾Óï·¨
Java SE5ÄÚÖÃÈýÖÖ±ê×¼×¢½â
@Override:±íʾµ±Ç°µÄ·½·¨¶¨Ò彫¸²¸Ç³¬ÀàÖеķ½·¨.Èç¹ûÄ㲻СÐÄƴд´íÎó,»òÕß·½·¨Ç©Ãû¶Ô²»Éϱ»¸²
¸ÇµÄ·½·¨,±àÒëÆ÷¾Í»á·¢³ö´íÎóÌáʾ
@Deprecated:Èç¹û³ÌÐòԱʹÓÃÁË×¢½âΪËüµÄÔªËØ,ÄÇô±àÒëÆ÷¾Í»á·¢³ö¾¯¸æÐÅÏ¢
@SupperessWarnings:¹Ø±Õ²»µ±µÄ±àÒëÆ÷¾¯¸æÐÅÏ¢.
Java SE5ÄÚÖÃËÄÖÖԪע½â
@Target:±íʾ¸Ã×¢½â¿ÉÒÔÓÃÓÚʲôµØ·½.¿ÉÄܵÄElementType²ÎÊý°üÀ¨:
1)CONSTRUCTOR:¹¹ÔìÆ÷µÄÉùÃ÷
2)FIELD:ÓòÉùÃ÷(°üÀ¨enumʵÀý)
3)LOCAL_VARIABLE:¾Ö²¿±äÁ¿ÉùÃ÷
4)METHOD:·½·¨ÉùÃ÷
5)PACKAGE:°üÉùÃ÷
6)PARAMETER:²ÎÊýÉùÃ÷
7)TYPE:Àà¡¢½Ó¿Ú(°üÀ¨×¢½âÀàÐÍ)»òenumÉùÃ÷
@Retention:±íʾÐèÒªÔÚʲô¼¶±ð±£´æ¸Ã×¢½âÐÅÏ¢.¿ÉÑ¡µÄRetentionPolicy²ÎÊý°üÀ¨:
1)SOURCE:×¢½â½«±»±àÒëÆ÷¶ªÆú
2)CLASS:×¢½âÔÚclassÎļþÖпÉÓÃ,µ«»á±»VM¶ªÆú
3)RUNTIME:VM½«ÔÚÔËÐÐÆÚÒ²±£Áô×¢½â,Òò´Ë¿ÉÒÔͨ¹ý·´Éä»úÖƶÁȡע½âµÄÐÅÏ¢
@Documented:½«´Ë×¢½â°üº¬ÔÚJavadocÖÐ
@Inherited:ÔÊÐí×ÓÀà¼Ì³Ð¸¸ÀàÖеÄ×¢½â
´ó¶àÊýʱºò,³ÌÐòÔ±Ö÷ÒªÊǶ¨Òå×Ô¼ºµÄ×¢½â£¬²¢±àд×Ô¼ºµÄ´¦ÀíÆ÷À´´¦ÀíËüÃÇ.
----------------------------- UseCase.java -------------------------
package com;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)//ÓÃÀ´¶¨ÒåÄãµÄ×¢½â½«Ó¦ÓÃÔÚʲôµØ·½,±¾´¦Ó¦ÓÃΪ·½·¨
//ÓÃÀ´¶¨Òå¸Ã×¢½âÔÚÄÄÒ»¸ö¼¶±ð¿ÉÓÃ,ÔÚÔ´´úÂëÖÐ(source)ÀàÎļþÖÐ(class)»òÕßÔËÐÐʱ(runtime)
@Retention(RetentionPolicy.RUNTIME)
public @interface UseCase {
public int id();
public String description()default "no description";
}
----------------------------- PasswordUtils .java&nb
Ïà¹ØÎĵµ£º
ÕâÊÇÒ»¸ö¼òµ¥µÄ·ÂÕæ³ÌÐò:
ÔÚÕâ¸ö·ÂÕæ³ÌÐòÖÐ,»¨Ô°Î¯Ô±»á¶¼Ï£ÍûÁ˽âÿÌìͨ¹ý´óÃŽøÈ빫԰µÄ×ÜÈËÊý.ÿ¸ö´óÃŶ¼ÓÐÒ»¸öÊ®×Ö
תÃÅ»òijÖÖÆäËûÐÎʽµÄ¼ÆÊýÆ÷,²¢ÇÒÈκÎÒ»¸öÊ®×ÖתÃŵļÆÊýÆ÷µÝÔöʱ,¾Í±íʾ¹«Ô°ÖеÄ×ÜÈËÊýµÄ¹²Ïí
¼ÆÊýÖµÒ²»áµÝÔö
package OrnamentalGarden;
import java.util.Random;
/**
* ÕâÀïʹÓõ¥¸öµ ......
java¶àÏß³ÌͨÐÅ ÊÕ²Ø
תÔØÇë×¢Ã÷:À´×Ôhttp://blog.csdn.net/M_ChangGong/ ×÷Õß:ÕÅÑà¹ã
java¶àÏß³ÌͨÐÅ£¬Ä£ÄâÉú²úÕß-Ïû·ÑÕß¹Øϵ¡£
µÚ1ÖÖʵÏÖ£¨¸ÃʵÏÖ´æÔÚÎÊÌ⣩£¬¾ßÌå´úÂëÈçÏ£º
view plaincopy to clipboardprint?
package com.zhangyg.thread.mytest;
/**
* Ä£ÄâÉú²úÕß- ......
Java™ ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍ volatile ±äÁ¿¡£ÕâÁ½ÖÖ»úÖƵÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐ Volatile ±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£ÔÚÕâÆÚµÄ Java ÀíÂÛÓëʵ¼ù
ÖУ¬Brian Goetz ½«½éÉܼ¸ÖÖÕýȷʹÓà volatile ±äÁ¿µÄģʽ£¬²¢Õë¶ÔÆäÊÊÓ ......
Cookie£º¼Ç¼Óû§µÇ½״̬£¬¿ÉÒÔÔÚ¿Í»§¶Ë´´½¨cookie£¬¿ÉÒÔʹÓû§µÚ¶þ´ÎµÇ½µÄʱºò²»ÓÃÊäÈëÓû§ÃûºÍÃÜÂ룬¼´¿ÉÒԵǽµ½Ö÷Ò³
Ö÷Òª´úÂ룺
LoginView ÖУº £¨»ñÈ¡cookie£©
//»ñÈ¡cookie
Cookie [] cs=request.getCookies();
String name="";
String value="";
if(null!=cs)
......