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£¬ÓÃÀ´²éѯËùÓеÄÊý¾Ý£¬ÓÃÀ´Õ¹Ê¾Êý¾Ý
}
Ïà¹ØÎĵµ£º
ºËÐÄ˼Ï룺°Ñº¬main·½·¨µÄÈë¿ÚÀàÌí¼Óµ½MANIFEST.MFÎļþÖС£
²½Ö裺
¼ÙÉèÓÐÁ½¸öÀàÎļþÒª´ò°ü£¬ËüÃÇ·Ö±ðÊôÓÚ²»Í¬µÄpackage¡£
package com.test.jar;
import java.awt.*;
import javax.swing.*;
public class Jar extends JFrame
{ ......
JDK1.4ÖÐ
Map map = new HashMap();
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
}
JDK1.5ÖÐ,Ó¦ÓÃÐÂÌØÐÔFor-EachÑ»·
Map m = new HashMap(); ......
JAVA£×Ö·û´®¹ýÂËÀà
package cn.com.hbivt.util;
/**
* Title:
*
* Description:
*
* Copyright: Copyright (c) 2005
*
* Company:
*
* @author not attributable
* @version 1.0
*/
public class StringUtils {
......
ÕâÊÇÒ»¸ö¼òµ¥µÄ·ÂÕæ³ÌÐò:
ÔÚÕâ¸ö·ÂÕæ³ÌÐòÖÐ,»¨Ô°Î¯Ô±»á¶¼Ï£ÍûÁ˽âÿÌìͨ¹ý´óÃŽøÈ빫԰µÄ×ÜÈËÊý.ÿ¸ö´óÃŶ¼ÓÐÒ»¸öÊ®×Ö
תÃÅ»òijÖÖÆäËûÐÎʽµÄ¼ÆÊýÆ÷,²¢ÇÒÈκÎÒ»¸öÊ®×ÖתÃŵļÆÊýÆ÷µÝÔöʱ,¾Í±íʾ¹«Ô°ÖеÄ×ÜÈËÊýµÄ¹²Ïí
¼ÆÊýÖµÒ²»áµÝÔö
package OrnamentalGarden;
import java.util.Random;
/**
* ÕâÀïʹÓõ¥¸öµ ......
2. Calendar ¶ÔÏóµÄÈÝ´íÐÔ£¬Lenient ÉèÖà ÎÒÃÇÖªµÀÌض¨µÄÔ·ÝÓв»Í¬µÄÈÕÆÚ£¬µ±Ò»¸öÓû§¸ø³ö´íÎóµÄÈÕÆÚʱ£¬Calendar ÈçºÎ´¦ÀíµÄÄØ£¿ import java.io.*;
import java.util.*; public class WhatIsCalendar
{
public static void main(String[] args) throws Exception{
......