jsp Session¹ÜÀí(ThreadLocal)
ÔÚ¸÷ÖÖSession ¹ÜÀí·½°¸ÖУ¬ ThreadLocal ģʽµÃµ½ÁË´óÁ¿Ê¹Óá£ThreadLocal ÊÇ
JavaÖÐÒ»ÖÖ½ÏΪÌØÊâµÄḬ̈߳󶨻úÖÆ¡£Í¨¹ýThreadLocal´æÈ¡µÄÊý¾Ý£¬×ÜÊÇÓ뵱ǰÏß³ÌÏà¹Ø£¬
Ò²¾ÍÊÇ˵£¬JVM Ϊÿ¸öÔËÐеÄỊ̈߳¬°ó¶¨ÁË˽Óеı¾µØʵÀý´æÈ¡¿Õ¼ä£¬´Ó¶øΪ¶àÏ̻߳·¾³³£³ö
ÏֵIJ¢·¢·ÃÎÊÎÊÌâÌṩÁËÒ»ÖÖ¸ôÀë»úÖÆ¡£
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÖªµÀ£¬SessionFactory¸ºÔð´´½¨Session£¬SessionFactoryÊÇÏß³Ì
°²È«µÄ£¬¶à¸ö²¢·¢Ï߳̿ÉÒÔͬʱ·ÃÎÊÒ»¸öSessionFactory ²¢´ÓÖлñÈ¡Session ʵÀý¡£¶ø
Session²¢·ÇḬ̈߳²È«£¬Ò²¾ÍÊÇ˵£¬Èç¹û¶à¸öÏß³ÌͬʱʹÓÃÒ»¸öSessionʵÀý½øÐÐÊý¾Ý´æÈ¡£¬
Ôò½«»áµ¼ÖÂSession Êý¾Ý´æÈ¡Âß¼»ìÂÒ¡£ÏÂÃæÊÇÒ»¸öµäÐ͵ÄServlet£¬ÎÒÃÇÊÔͼͨ¹ýÒ»¸öÀà
±äÁ¿sessionʵÏÖSessionµÄÖØÓã¬ÒÔ±ÜÃâÿ´Î²Ù×÷¶¼ÒªÖØд´½¨£º
public class TestServlet extends HttpServlet {
private Session session;
public void doGet( HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
session = getSession();
doSomething();
session.flush();
}
public void doSomething(){
......//»ùÓÚsessionµÄ´æÈ¡²Ù×÷
}
}
´úÂë¿´ÉÏÈ¥ÕýÈ·ÎÞÎó£¬ÉõÖÁÔÚÎÒÃǵ¥»ú²âÊÔµÄʱºò¿ÉÄÜÒ²²»»á·¢ÉúʲôÎÊÌ⣬µ«ÕâÑùµÄ´ú
Hibernate Developer’s Guide Version 1.0
September 2, 2004 So many open source projects. Why not Open your Documents?
ÂëÒ»µ©±àÒ벿Êðµ½Êµ¼ÊÔËÐл·¾³ÖУ¬½Óõà¶øÀ´µÄĪÃûÆäÃîµÄ´íÎóºÜ¿ÉÄÜ»áʹµÃÎÒÃÇÃþ²»ÕÒÍ·ÄÔ¡£
ÎÊÌâ³öÔÚÄÄÀ
Ê×ÏÈ£¬Servlet ÔËÐÐÊǶàÏ̵߳ģ¬¶øÓ¦Ó÷þÎñÆ÷²¢²»»áΪÿ¸öÏ̶߳¼´´½¨Ò»¸öServlet
ʵÀý£¬Ò²¾ÍÊÇ˵£¬TestServletÔÚÓ¦Ó÷þÎñÆ÷ÖÐÖ»ÓÐÒ»¸öʵÀý£¨ÔÚTomcatÖÐÊÇÕâÑù£¬ÆäËûµÄ
Ó¦Ó÷þÎñÆ÷¿ÉÄÜÓв»Í¬µÄʵÏÖ£©£¬¶øÕâ¸öʵÀý»á±»Ðí¶à¸öÏ̲߳¢·¢µ÷Óã¬doGet ·½·¨Ò²½«±»²»
ͬµÄÏ̷߳´¸´µ÷Ó㬿ÉÏë¶øÖª£¬Ã¿´Îµ÷ÓÃdoGet ·½·¨£¬Õâ¸öΨһµÄTestServlet ʵÀýµÄ
session ±äÁ¿¶¼»á±»ÖØÖã¬Ïß³ÌA µÄÔËÐйý³ÌÖУ¬ÆäËûµÄÏß³ÌÈç¹ûÒ²±»Ö´ÐУ¬ÄÇôsession
µÄÒýÓý«·¢Éú¸Ä±ä£¬Ö®ºóÏß³ÌA ÔÙµ÷ÓÃsession£¬¿ÉÄÜ´ËʱµÄsession ÓëÆä֮ǰËùÓõÄ
session¾Í²»ÔÙÒ»Ö£¬ÏÔÈ»£¬´íÎóÒ²¾Í²»ÆÚ¶øÖÁ¡£
ThreadLocalµÄ³öÏÖ£¬Ê¹µÃÕâ¸öÎÊÌâÓÈжø½â¡£
ÎÒÃǶÔÉÏÃæµÄÀý×Ó½øÐÐһЩССµÄÐ޸ģº
public class TestServlet extends HttpServlet {
private ThreadLocal localSession = new ThreadLocal();
public void
Ïà¹ØÎĵµ£º
1¡¢ ×î»ù±¾µÄÂÒÂëÎÊÌâ¡£
Õâ¸öÂÒÂëÎÊÌâÊÇ×î¼òµ¥µÄÂÒÂëÎÊÌâ¡£Ò»°ãлá³öÏÖ¡£¾ÍÊÇÒ³Ãæ±àÂë²»Ò»Öµ¼ÖµÄÂÒÂë¡£
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=iso8859-1"%>
<html>
<head>
<title>ÖÐÎÄÎÊÌâ</title>
<meta http-equi ......
Jsp³£Óü¼ÇÉ:ͼƬÑéÖ¤Âë
2009Äê10ÔÂ30ÈÕ ÐÇÆÚÎå 21:06
˼·
£º
ͼƬÑéÖ¤ÂëµÄʵÏÖÖ÷ÒªµÄ¼¼ÊõµãÊÇÈçºÎÉú³ÉÒ»¸öͼƬ¡£Éú³ÉͼƬ¿ÉÒÔʹÓÃjava.awt°üϵÄÀàÀ´ÊµÏÖ¡£ÎÒÃÇÏÈдһ¸ö¼òµ¥µÄÉú³ÉͼƬµÄ³ÌÐòHelloImage.java¡£ÒÔÏÂÊÇ´úÂ벿·Ö¡£
package com.vogoal.test;
import java.awt.Color;
import
java.awt.Graphics;
imp ......
package com.demo.filter;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterChain;
import java.io.IOException;
public class SetCharacterEn ......
http://www.ajaxbbs.net/post/extjs/10.html
ÓйØExtGridµ¼³öExcelµÄʵÏÖ·½Ê½£¬ÍøÉÏÒѾÓкܶ࣬¹Ù·½Ò²¸ø³öÁËÒ»¸ö·½°¸£¬´úÂë²»ÊǺÜÍêÉÆ£¬²»¹ýÒѾÓиßÈ˶ÔÕâ¸ö½øÐÐÁËÐÞÕý¡£¾ßÌåʵÏÖ·½Ê½¼°´úÂëÎÒÕâÀï¾Í²»ÔÙ¶à˵ÁË£¬´ó¼Ò¿ÉÒԲο´£º
http://www.dojochina.com/index.php?q=node/1254
£¬¸½¼þ£º
gridToExcel.js.txt
Æä»ù± ......
1¡¢Out¶ÔÏó
Ö÷ÒªÓÃÀ´Ïò¿Í»§¶ËÊä³ö¸÷ÖÖ¸ñʽµÄÊý¾Ý£¬²¢ÇÒ¹ÜÀíÓ¦Ó÷þÎñÆ÷ÉϵÄÊä³ö»º³åÇø£¬Out¶ÔÏóµÄ»ùÀàÊÇjavax.servlet.jsp.JspWriterÀà¡£
OutµÄÖ÷Òª·½·¨£º
out.println(DataType);»òout.print(DataType);
ʵÀý£º
<%@page language="java"
contentType="text/html;charset=gb2312"
import="java.util.*"
%>
&l ......