JavaÓû§»Øµ÷·½·¨Ïû³ýÈßÓà´úÂë
Ò». ¿´Ò»¶ÎÈßÓàµÄ´úÂë
public String login(HttpServletRequest request){
OperatorService operatorService = new OperatorService();
WebContext webContext= request.getSession().getAttribute("WEB_CONTEXT_KEY");
Connection conn=null;
try{
Conection conn =DBManager.getConnection();
if(webContext.getOperatorName.equals("123")){
// µÇ½³É¹¦
}
}catch(Throwable t){
//¼Ç¼ÈÕÖ¾
//Ìø×ªµ½Í³Ò»µÄ´íÎóÒ³Ãæ,²»ÄÜÈÃÓû§¿´µ½Òì³£Ò³Ãæ
//¹Ø±ÕConnection
if(conn!=null){
try{conn.close();}cath(SQLException ex){}
}
}
}
public String logOut(HttpServletRequest request){
OperatorService operatorService = new OperatorService();
WebContext webContext= request.getSession().getAttribute("WEB_CONTEXT_KEY");
try{
Conection conn =DBManager.getConnection();
operatorService.logout();
request.getSession().invalidate();
}catch(Throwable t){
//¼Ç¼ÈÕÖ¾
//Ìø×ªµ½Í³Ò»µÄ´íÎóÒ³Ãæ,²»ÄÜÈÃÓû§¿´µ½Òì³£Ò³Ãæ
//¹Ø±ÕConnection
if(conn!=null){
try{conn.close();}cath(SQLException ex){}
}
}
}
¶þ¡¢¿ÉÒÔ¿´µ½,ºìÉ«²¿·Ö´úÂëÍêÈ«ÊÇÈßÓàµÄ£¬ÏÂÃæÓûص÷·½·¨¼ò»¯Õⲿ·Ö´úÂë
1.Ïȶ¨ÒåÒ»¸ö»Øµ÷³éÏóÀà
public abstract class AppCallback {
/**
* »Øµ÷Ö´Ðз½·¨
*
* @return
*/
public String execute() {
&n
Ïà¹ØÎĵµ£º
java¶àÏß³ÌͨÐÅ ÊÕ²Ø
×ªÔØÇë×¢Ã÷:À´×Ôhttp://blog.csdn.net/M_ChangGong/ ×÷Õß:ÕÅÑà¹ã
java¶àÏß³ÌͨÐÅ£¬Ä£ÄâÉú²úÕß-Ïû·ÑÕß¹ØÏµ¡£
µÚ1ÖÖʵÏÖ£¨¸ÃʵÏÖ´æÔÚÎÊÌ⣩£¬¾ßÌå´úÂëÈçÏ£º
view plaincopy to clipboardprint?
package com.zhangyg.thread.mytest;
/**
* Ä£ÄâÉú²úÕß- ......
MonoRailÊǾµäµÄMVCģʽ,ËùÒÔÆäÖÐÒ²¾ßÓÐÈý¸öÔªËØModel,Controller,View,ÆäÖÐMonoRailÊÇͨ¹ýUrlµØÖ·À´½âÎö
ÏàÓ¦µÄ²Ù×÷µÄ,Èçµ±Äã·ÃÎÊ:/home/index.rail,¶ÔÓ¦»áÖ´ÐÐHomeControllerÀàÖеÄIndex·½·¨,¶øÇÒ¿ÉÒÔ×Ô¶¯°ó¶¨²ÎÊýºÍ
RequestµÄÊý¾Ý,Èç·ÃÎÊ:/home/index.rail?id=1,Äã¿ÉÒÔÔÚHomeControllerÀàÖеÄIndex·½·¨Öж¨ÒåÒ»¸ö²ÎÊý ......
Cookie£º¼Ç¼Óû§µÇ½״̬£¬¿ÉÒÔÔÚ¿Í»§¶Ë´´½¨cookie£¬¿ÉÒÔʹÓû§µÚ¶þ´ÎµÇ½µÄʱºò²»ÓÃÊäÈëÓû§ÃûºÍÃÜÂ룬¼´¿ÉÒԵǽµ½Ö÷Ò³
Ö÷Òª´úÂ룺
LoginView ÖУº £¨»ñÈ¡cookie£©
//»ñÈ¡cookie
Cookie [] cs=request.getCookies();
String name="";
String value="";
if(null!=cs)
......
JVM£º¼ÓÔØ¡¢Á´½ÓºÍ³õʼ»¯
JVMÒª½âÊÍJava×Ö½ÚÂ룬¾Í±ØÐë¶ÔËùÐèµÄÀàºÍ½Ó¿ÚÖ´ÐÐÈçÏÂ3²½²Ù×÷£º
(1) ¼ÓÔØ£ºJVMÔÚ¼ÓÔØÀàʱ£¬»á²éÕÒ¸ÃÀà»ò¸Ã½Ó¿ÚµÄ¶þ½øÖƱíʾ£¬²¢¸ù¾ÝÕÒµ½µÄ¶þ½øÖƱíʾ(ͨ³£ÊÇÓÉJava±àÒëÆ÷´´½¨µÄÀàÎļþ)´´½¨Ò»¸öClass¶ÔÏ󡣸ÃClass¶ÔÏóÖзâ×°ÁËÀà»ò½Ó¿ÚµÄÔËÐÐʱ״̬¡£
(2) Á´½Ó£ºÁ´½ÓÕâÒ»¹ý³ÌÊÇָȡµÃÒѼÓÔØµÄ ......
JDK 5.0 ÖÐÔö¼ÓµÄ·ºÐÍÀàÐÍ£¬ÊÇ Java ÓïÑÔÖÐÀàÐͰ²È«µÄÒ»´ÎÖØÒª¸Ä½ø¡£µ«ÊÇ£¬¶ÔÓÚ³õ´ÎʹÓ÷ºÐÍÀàÐ͵ÄÓû§À´Ëµ£¬·ºÐ͵ÄijЩ·½Ãæ¿´ÆðÀ´¿ÉÄܲ»ÈÝÒ×Ã÷°×£¬ÉõÖÁ·Ç³£Ææ¹Ö¡£ÔÚ±¾ÔµēJava ÀíÂÛºÍʵ¼ù”ÖУ¬Brian Goetz ·ÖÎöÁËÊø¸¿µÚÒ»´ÎʹÓ÷ºÐ͵ÄÓû§µÄ³£¼ûÏÝÚå¡£Äú¿ÉÒÔͨ¹ýÌÖÂÛÂÛ̳Óë×÷ÕßºÍÆäËû¶ÁÕß·ÖÏíÄú¶Ô±¾ÎĵĿ´·¨¡ ......