Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java ÖÐ CookieµÄÓ÷¨

Cookie£º¼Ç¼Óû§µÇ½״̬£¬¿ÉÒÔÔÚ¿Í»§¶Ë´´½¨cookie£¬¿ÉÒÔʹÓû§µÚ¶þ´ÎµÇ½µÄʱºò²»ÓÃÊäÈëÓû§ÃûºÍÃÜÂ룬¼´¿ÉÒԵǽµ½Ö÷Ò³
Ö÷Òª´úÂ룺  
LoginView ÖУº £¨»ñÈ¡cookie£©
//»ñÈ¡cookie
Cookie [] cs=request.getCookies();
String name="";
String value="";
if(null!=cs)
{   
   System.out.println("cs.length:"+cs.length);
   for(int i=0;i<cs.length;i++)
   {
      Cookie c=cs[i];
      name=c.getName();
      value=c.getValue();
   }
}
if(null!=cs&&!(name.trim().equals("JSESSIONID")))
{
   request.setAttribute("username",name);
   request.setAttribute("userpass",value);
   request.getRequestDispatcher("/servlet/Controller1").forward(request,response);
}
Controller ¿ØÖÆÆ÷ÖУº£¨´´½¨cookie£©
if(sflag)   // if µÇ½³É¹¦£¨sflag±íʾ£¬ÑéÖ¤Óû§³É¹¦£©
{
if(usercheckbox==null)
{
//System.out.println("ÄúûÓÐÑ¡ÖУ¡£¡£¡");   //ûÓÐÑ¡ÖУ¬ÎÞ²Ù×÷
}
else
{
//System.out.println("ÄúÒÔÑ¡ÖУ¡");    // Èç¹ûÑ¡ÖУ¬Ôò´´½¨cookie
//´´½¨cookie
Cookie cookie=new Cookie(username,userpass);
//ÉèÖÃcookieµÄʱЧ
cookie.setMaxAge(60*60*24*7*2);
//ÉèÖÃcookie µÄʹÓ÷¾¶
cookie.setPath("/");
//·¢ËÍcookie
response.addCookie(cookie);
}
HttpSession session=request.getSession();
session.setAttribute("userinfo",username); //°ó¶¨Óû§Ãû
response.sendRedirect("/hygj0331/servlet/Controller3");
             //·¢Ë͵½¿ØÖÆÆ÷Controller3£¬ÓÃÀ´²éѯËùÓеÄÊý¾Ý£¬ÓÃÀ´Õ¹Ê¾Êý¾Ý
}


Ïà¹ØÎĵµ£º

javaÉú³Éxml¸ñʽÊý¾Ý

//»ñÈ¡Êý¾Ý¿âÊý¾Ý·µ»Ølist
public List queryAll(int fcateId) {
List list = new ArrayList();
String sql = "select * from g_Account where fCateID=? order by fCode";
Connection con = SqlHelp.getConn();//»ñµÃÁ¬½Ó£¬sqlhelp×Ô¼ºÐ´µÄ¹¤¾ßÀà
PreparedStatement pst = null;
ResultSet rs = null;
......

javaµÄ·¢Éä»úÖÆ

Person p=new Person();
ÕâÊÇʲô?µ±È»ÊÇʵÀý»¯Ò»¸ö¶ÔÏóÁË.¿ÉÊÇÕâÖÖʵÀý»¯¶ÔÏóµÄ·½·¨´æÔÚÒ»¸öÎÊÌâ,ÄǾÍÊDZØÐëÒªÖªµÀÀàÃû²Å¿ÉÒÔʵÀý»¯ËüµÄ¶ÔÏó,ÕâÑùÎÒÃÇÔÚÓ¦Ó÷½Ãæ¾Í»áÊܵ½ÏÞÖÆ.ÄÇôÓÐûÓÐÕâÑùÒ»ÖÖ·½Ê½,ÈÃÎÒÃDz»ÖªµÀÕâ¸öÀàµÄÀàÃû¾Í¿ÉÒÔʵÀý»¯ËüµÄ¶ÔÏóÄØ?Thank Goodness!ÐÒ¿÷ÎÒÃÇÓõÄÊÇjava, java¾ÍÌṩÁËÕâÑùµÄ»úÖÆ.
1).ja ......

3¸ö²»³£ÓõÄjava¹Ø¼ü×Ötransient¡¢volatile¡¢strictfp

(1) transient:
Èç¹ûÓÃtransientÉùÃ÷Ò»¸öʵÀý±äÁ¿£¬µ±¶ÔÏó´æ´¢Ê±£¬ËüµÄÖµ²»ÐèҪά³Ö¡£ÀýÈ磺
class T
{  
      transient int a;  //²»ÐèҪά³Ö
      int b;  //ÐèҪά³Ö
}  //ÕâÀÈç¹ûTÀàµÄÒ»¸ö¶ÔÏóдÈëÒ»¸ö³Ö¾ÃµÄ´æ´¢ÇøÓò£¬aµ ......

java¶àÏß³ÌÖ®¼äµÄͨÐÅ

java¶àÏß³ÌͨÐÅ ÊÕ²Ø
תÔØÇë×¢Ã÷:À´×Ôhttp://blog.csdn.net/M_ChangGong/ ×÷Õß:ÕÅÑà¹ã
java¶àÏß³ÌͨÐÅ£¬Ä£ÄâÉú²úÕß-Ïû·ÑÕß¹Øϵ¡£
µÚ1ÖÖʵÏÖ£¨¸ÃʵÏÖ´æÔÚÎÊÌ⣩£¬¾ßÌå´úÂëÈçÏ£º
 view plaincopy to clipboardprint?
package com.zhangyg.thread.mytest;  
 
/** 
 * Ä£ÄâÉú²úÕß- ......

JavaÀà¼ÓÔØÔ­Àí¼°×Ô¶¨ÒåÀà¼ÓÔØÆ÷

        JavaºÍÆäËûÓïÑÔ²»Í¬µÄÊÇ£¬JavaÊÇÔËÐÐÓÚJavaÐéÄâ»ú(JVM)¡£Õâ¾ÍÒâζ×űàÒëºóµÄ´úÂëÊÇÒÔ
Ò»ÖÖºÍƽ̨Î޹صĸñʽ±£´æµÄ£¬¶ø²»ÊÇijÖÖÌض¨µÄ»úÆ÷ÉÏÔËÐеĸñʽ¡£ÕâÖÖ¸ñʽºÍ´«Í³µÄ¿É
Ö´ÐдúÂë¸ñʽÓкܶàÖØÒªµÄÇø±ð¡£¾ßÌåÀ´Ëµ£¬²»Í¬ÓÚC»òÕߣÃ++³ÌÐò£¬Java³ÌÐò²»ÊÇÒ»¸ö¶À
Á¢µÄ¿ÉÖ´ÐÐÎļ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ