java webÖж¨Ê±Æ÷µÄÔËÓÃ
ÔÚ×öweb¿ª·¢µÄʱºò£¬¾³£ÐèÒªÔÚÒ»¶¨µÄʱ¼äÈ¥¸úÐÂijЩ¶«Î÷£¬»òÊǼÓÔØijЩ¶«Î÷£¬Õâ¾ÍÓõ½Á˶¨Ê±Æ÷¡£
µ±Web¹¤³ÌÆô¶¯Ê±£¬¶¨Ê±Æ÷ÄÜ×Ô¶¯¿ªÊ¼¼Æʱ£¬ÔÚÕû¸öWeb¹¤³ÌµÄÉúÃüÆÚÀ¶¨Ê±Æ÷ÿ¹ýÒ»¶Îʱ¼ä¾ÍÖ´ÐÐÒ»´Î£¬ËùÒÔ¿¼ÂǶ¨Ê±Æ÷´æ·ÅµÄλÖá£
¶¨Ê±Æ÷¿Ï¶¨²»Äܲ»Äܼòµ¥µÄ´æÔÚÓÚµ¥¸öServlet»òJavaBeanÖУ¬±ØÐëÄÜÈö¨Ê±Æ÷ËÞÖ÷µÄ´æ»îÆÚΪÕû¸öWeb¹¤³ÌÉúÃüÆÚ£¬ÔÚ¹¤³ÌÆô¶¯Ê±ÄÜ×Ô¶¯¼ÓÔØÔËÐС£½áºÏÕâÁ½µã£¬¸ú ServletÉÏÏÂÎÄÓйصÄÕìÌýÆ÷¾Í×îºÏÊʲ»¹ýÁË£¬Í¨¹ýÔÚ¹¤³ÌµÄÅäÖÃÎļþÖмÓÒÔºÏÀíÅäÖ㬻áÔÚ¹¤³ÌÆô¶¯Ê±×Ô¶¯ÔËÐУ¬²¢ÔÚÕû¸ö¹¤³ÌÉúÃüÆÚÖд¦ÓÚ¼àÌý״̬¡£
ÏÂÃæ¾ÍServletÕìÌýÆ÷½áºÏJava¶¨Ê±Æ÷À´½²ÊöÕû¸öʵÏÖ¹ý³Ì£º
import java.util.Timer;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpServlet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @date 2010-1-14
* @author wangpeng
* ¹¦ÄÜ£º¼àÌýÆ÷£¬ÓÃÀ´ÊµÏÖ¼ÆʱÆ÷
*/
public class ContextListener extends HttpServlet implements
ServletContextListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(NewsTimerTask.class);
public ContextListener() {
}
private Timer timer = null;
public void contextInitialized(ServletContextEvent event) {
timer = new Timer(true);
log.info("¶¨Ê±Æ÷ÒÑÆô¶¯");
timer.schedule(new NewsTimerTask(event.getServletContext()),
TIME_NEWS_DELAY, TIME_NEWS_PERIOD);
log.info("ÒѾÌí¼ÓÈÎÎñµ÷¶È±í");
}
public void contextDestroyed(ServletContextEvent event) {
timer.cancel(); //¶¨Ê±Æ÷µÄÏú»Ù
log.info("¶¨Ê±Æ÷Ïú»Ù");
}
}
NewsTimerTask- ËùÒª°²ÅŵÄÈÎÎñ¡£ TIME_NEWS_DELAY - Ö´ÐÐÈÎÎñÇ°µÄÑÓ³Ùʱ¼ä£¬µ¥Î»ÊǺÁÃë¡£ Ϊ0ʱ±íÃ÷²»ÑÓ³ÙTIME_NEWS_PERIOD - Ö´Ðи÷ºóÐøÈÎÎñÖ®¼äµÄʱ¼ä¼ä¸ô£¬µ¥Î»ÊǺÁÃë¡£
NewsTimerTask¼Ì³ÐTimerTask
TimerTaskÊÇ ÓÉ Timer °²ÅÅΪһ´ÎÖ´Ðлò
Ïà¹ØÎĵµ£º
Èç¹ûҪʹÖ÷´°¿Ú ¾ÓÖÐÒ»°ãʹÓÃÏÂÃæµÄ·½·¨£º
import javax.swing.*;
import java.awt.*;
public class ToCenter
{
public ToCenter(JFrame frame)
{
//---------------------------ÉèÖô°¿Ú¾ÓÖÐ---------------------------------------------------- ......
±¾ÎÄÄÚÈÝÕª×Ô£º¡¶Java Web¿ª·¢½Ì³Ì——ÈëÃÅÓëÌá¸ßƪ£¨JSP+Servlet£©¡·
AJAXÊÇAsynchronous JavaScript and XMLµÄËõд£¬Éæ¼°JavaScript½Å±¾¡¢XHTMLºÍCSS¡¢DOM¡¢XMLºÍXSTLµÈ¼¼Êõ¡£
l XHTMLÓëCSSʵÏÖÊý¾ÝÐÅÏ¢µÄͳһ»¯ºÍ±ê×¼»¯ÏÔʾ£»
l & ......
javaµ÷webServiceÌ«Õý³£ÁË¡£¡£¡£
ÔÚµ÷ÓÃhttpsµÄwebServiceµÄʱºò¼¸ÖÖ³£Óõķ½·¨»á³öÏÖ°²È«´íÎ󣬺ܶàÈË˵µÄÊÇÔÚjreÀïÃæ×°Ö¤Êé¡£¡£¡£ÄÇҲ̫ÓôÃÆÁË°É
ÕâÀïÌṩһÖÖ²»ÓÃÖ¤ÊéµÄ·½Ê½
¶Ô·½webServiceÌṩµÄ½Ó¿Ú£¬Õâ¸öÄãÓ¦¸ÃÒªÖªµÀµÄ°É£¬²»ÖªµÀµÄ»°¾Íwsdl×Ô¼º»¹Ô
Java´úÂë
/**
* XXXµÄwebService½Ó¿ ......
Õâ¸ö¿ò¼ÜÒ²ÊÇΪgoogle app engine×¼±¸µÄ¡£µ±Ê±¸Ð¾õÖ±½ÓÔÚgaeÉÏsevletÌ«·³ÈËÁË£¬¾Í·â×°¸ö¼òÒ׵Ŀò¼Ü¡£Ê¹ÓõÄʱºòÖ»ÐèÒªÅäÖÃweb.xmlÖÐDispacherSevletºÍpackage.propertiesÖеÄpackage.path£¨Ä¬ÈÏɨÃèµÄ°ü£©¼´¿É
gaeÀý×Ó£ºhttp://orzblogs.appspot.com/Home.htm
´óѧµÄʱºòºÜBS java£¬Ñ§ÁËÖ®ºó¾ÍÈÓµôÁË£¬ÏÖÔÚ¹¤×÷Á˲ſªÊ¼ ......
ÔÚJavaÓ¦ÓÃÖУ¬ÈÕÆÚºÍʱ¼ä×÷Ϊ»ù±¾µÄÐÅÏ¢ÀàÐÍÓ¦ÓõÄÌرð¹ã·º£¬ÀýÈç»ñÈ¡µ±Ç°Ê±¼ä£¬¼ÆËãijЩ²Ù×÷Ö´ÐеÄʱ¼äµÈ¡£ÈÕÆÚ´¦ÀíÏà¹ØµÄÀà°üÀ¨DateºÍCalendar£¬Í¨¹ýDateºÍCalendar¿ÉÒÔ»ñÈ¡µ±Ç°Ê±¼ä£¬¶Ôʱ¼ä½øÐÐһЩÔËË㣬»ñȡʱ¼äÖеÄÄê¡¢Ô¡¢ÈÕ¡¢Ê±¡¢·Ö¡¢ÃëºÍÐÇÆÚµÈÐÅÏ¢¡£ÔÚÊäÈëºÍÊä³öµÄʱºò¾³£Óõ½×Ö·û´®ÐÎʽµÄʱ¼ä£¬Õâ¾ÍÐèҪʱ¼äºÍ ......