ÕâÊÇJAVAÀïµÄʲôÓ÷¨£¿ - Java / Java SE
¸Õ²Å¿´HIBERNETÀïµÄÒ»¸öÀàÀïÓÐÈçϺìÉ«´úÂ룬¿ÉÒÔ²»Óú¯ÊýÃûµÄÂð£¿Õâ½Ð×öʲôÓ÷¨£¿
Java code:
package db;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
/**
* Configures and provides access to Hibernate sessions, tied to the
* current thread of execution. Follows the Thread Local Session
* pattern, see {@link http://hibernate.org/42.html }.
*/
public class HibernateSessionFactory {
/**
* Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.
* The default classpath location of the hibernate config file is
* in the default package. Use #setConfigFile() to update
* the location of the configuration file for the current session.
*/
private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
private static final ThreadLocal threadLocal = new ThreadLocal();
private static Configuration configuration = new Configuration();
private static org.hibernate.SessionFactory sessionFactory;
private static String configFile = CONFIG_FILE_LOCATION;
[color=#FF0000]static {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessi
Ïà¹ØÎÊ´ð£º
ÌâÄ¿£º
ÓÐ1,2,3£¬4,5,6Áù¸öÊý×ÖÅÅÐò£¬ÓÃjava³ÌÐò¼ÆËã³öÅÅÐòµÄÖÖÀà¡£
ÒªÇó£ºÒ»£¬ÒÔ4¿ªÍ·
¶þ£¬2,3²»ÄÜÏàÁÚ
Èý£¬²»ÄÜÒÔ5¿ªÍ·
Ï£Íû´ó¼ÒÄܼ´ ......
ΪʲôHTMLÒÔ¼°Ò»Ð©ÆäËü±êÇ©»áÏÔÊ¾Ò»Ð©ÌØ¶¨±íÏÖÐÎÊ½ÄØ£¿ÈçHTMLÖеĻ»ÐбêÇ©<BR/>ÔڵײãÊÇÔõÑùʵÏÖµÄÄØ£¿ÏÖʵµÄÔÀíÊÇÊ²Ã´ÄØ
È¥W3C¹Ù·½ÍøÕ¾ÉÏ£¬¿´¿´°É£¡ÎÒÏëÒ»¿´Äã¾ÍÃ÷°×ÁË
ÎҲºͱàÒëÔÀíÓйأ¬ä¯ÀÀÆ÷Àï¿É ......
ÓÐËÓÃjava×ö¹ý´òÓ¡·¢Æ±µÄ³ÌÐò£¬¸Ð¾õÕâ·½Ãæ²»ÊǺܺÿØÖÆ£¬Ï£Íû¸øµã½¨Ò飬×îºÃÄܸø³ö´úÂë
¼òµ¥µã¾Íµ÷ÓÃwindow.print()
ÄãÒ²¿ÉÒÔ°ÑÏÂÃæ´úÂë·Åµ½ÄãJSPÖÐ:
<html>
<head>
<title> ......
¾ÍÊǼòµ¥µÄ´«ÖµºÍȡֵ
ÇëÎÊÂ¥Ö÷ÏëÎÊʲô£¿
jspÒ³Ãæ²ÉÓÃ±íµ¥»òÕßjavabean´«Öµ¶¼¿ÉÒÔ£¬Ê¹ÓÃrequest.getParameter()»ñµÃʹÓÃ±íµ¥´«¹ýÀ´µÄÖµ¡£
ÎÊÎÊÌ⣬ÏȰÑÎÊÌâ˵Çå³þµã£¡£¡ ÎÊÌâ̫ģºý£¡£¡
ÎÊÎÊÌ⣬ÏȰÑÎ ......