JavaÖÐÈçºÎÖ´ÐÐJavaScript
ÎÒÃÇÔÚ½øÐÐWEB¿ª·¢µÄʱºò£¬¾³£ÐèÒªÔÚ¿Í»§¶Ë±àдһЩjsº¯Êý£¬ÕâЩº¯ÊýÈç¹ûÐèÒªÔÚ·þÎñ¶ËÖ´ÐеĻ°£¬Èç¹ûÖØбàдµÄ»°£¬¾ÍÏÔµÃÊ®·ÖÈßÓ࣬Òò´ËÎÒÃÇ¿ÉÒÔ³¢ÊÔÔÚ·þÎñ¶Ë£¬Ö±½ÓÖ´ÐÐjs£¬ÕâÑùµÄ»°¾Í¿ÉÒÔ±ÜÃâÖظ´ÀͶ¯£¬Í¬Ê±£¬µ÷ÓÃjsÒ²Óиöº¯Êý£¬¾ÍÊǷdz£·½±ãµ÷ÊÔ¡£
×î¹Ø¼üµÄÒ»²½¾ÍÊǵ÷ÓÃ
conext.evaluateString(scope, "scriptÄÚÈÝ", "", 1, null); ½«js×°Èë·þÎñ¶ËÈÝÆ÷ÖÐ ¶øÕâ¸öÍùÍùÖ»ÐèÒª³õʼ»¯Ò»´Î¼´¿É
ÏÂÃæ¸ø³öÒ»¸ö¾ßÌåµÄÓÃÀý£¬¹©²Î¿¼£º
/*
* (non-Javadoc)
*
* @see ygfmis.fw.system.scripting.ScriptEvaluator#evaluateExpression(java.lang.String,
* java.util.Map, java.lang.Class)
*/
public Object evaluateExpression(String expr) {
initJavaScriptContext();
java.lang.Object eval;
try {
if (log.isDebugEnabled()) {
log.debug("Evaluating javascript expression:" + expr);
}
eval = conext.evaluateString(scope, expr, "", 1, null);
if (log.isDebugEnabled()) {
log.debug("JavaScriptEvaluator->Javascript expression " + expr
+ " is evaluated to " + eval);
}
return eval;
} catch (Exception jse) {
if (log.isErrorEnabled()) {
log.error("JavaScriptEvaluator -> The result of expression "
+ expr + " can't be evaluated - error message="
+ jse.getMessage(), jse);
}
throw new ScriptException("Result cannot be evaluated", jse);
} finally {
//org.mozilla.javascript.Context.exit();
}
}
private static org.mozilla.javascript.Context conext = null;
private static Scriptable scope = null;
/**
* YGFMISWebµÄµØÖ·.
*/
privat
Ïà¹ØÎĵµ£º
֮ǰ51CTOÔø·¢¹ýһƪÎÄÕ½Ð×ö¡¶OSGiΪʲôÖØÒª£ºÏòÄ£¿é»¯×ªÒƵÄÖ÷¹¥ÊÖ
¡·£¬ÀïÃæ¶ÔÓÚOSGiµÄÓÅÊƽøÐÐÁË·ÖÎö¡£²»¹ý£¬¶ÔÓÚ
¾¿¾¹Ê²Ã´ÊÇOSGi£¬ºÜ¶àÈËÈÔȻֻÓÐÒ»¸öÄ£ºýµÄ¸ÅÄî¡£±¾ÏµÁУ¨ÄãºÃ£¬OSGi
£©´Ó»ù´¡¿ª
ʼ½éÉÜÁËOSGi¡£±¾²¿·Ö½éÉÜOSGiÊÇʲô£¬ÒÔ¼°OSGiÈÝÆ÷µÄһЩÏÖ×´¡££¨×¢£º±¾ÎÄÓ¢ÎÄÔÎÄÓÚ08Äê3Ô·¢²¼ÔÚJavaWorldÍøÕ¾£©
......
ÐÞ¸ÄJavaÎļþ²»ÓÃÖØÆôTomcat·þÎñµÄ·½·¨
ÔÚʹÓÃEclipse+Tomcat¿ª·¢JavaÏîÄ¿µÄʱºò³£³£»áÅöµ½ÕâÑùµÄÇé¿ö£¬ÒÑÐÞ¸ÄJavaÎļþTomcat¾Í»á×Ô¶¯ÖØÆô£¬½ÓÏÂÀ´¾ÍÊÇÂþ³¤µÄµÈ´ý·þÎñÖØÆôÍê±Ï¡£ÄÇÆäʵ´ó¶àÊýµÄJavaÎļþÐÞ¸ÄÊÇûÓбØÒªÖØÆô·þÎñµÄ£¬Ö»ÓÐһЩÌض¨µÄJavaÎļþ£¬±ÈÈç˵ֻÓÐÖØÆô·þÎñµÄʱºò²Å»áµ÷Ó ......
ÀàµÄ°ü·ÃÎÊȨÏÞ£º¡¶Java±à³Ì˼Ïë¡·ÖÐÒ»¶Î»°µÄÀ§»ó
ÔÚ¡¶java±à³Ì˼ÏëµÚÈý°æ¡·£¨³Âê»Åô ÈÄÈô骵ÈÒ룩µÄµÚÎåÕÂÒþ²Ø¾ßÌåʵÏÖÖУ¬5.4½ÚµÄ×îºóÒ»¶Î»°ÊÇ£º
“ÕýÈçÇ°ÃæËùÌáµ½µÄ£¬Èç¹ûûÄÜΪÀà·ÃÎÊȨÏÞÖ¸¶¨Ò»¸ö·ÃÎÊÐÞÊηû£¬Ëü¾Í»áȱʡµÃµ½°ü·ÃÎÊȨÏÞ¡£ÕâÒâζןÃÀàµÄ¶ÔÏó¿ÉÒÔÓÉ°üÄÚÈκÎÆäËûÀàÀ´´´½¨£ ......
public String getCheckDateString(String str) {
Date date = new Date();//»ñÈ¡µ±Ç°ÏµÍ³ÈÕÆÚ
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");//ʱ¼ä¸ñʽ
......
ÎÒÃÇҪʵÏֵľßÌ幦ÄÜÊÇ£º
ÀûÓÃSocketÀàºÍServerSocketÀà±àдһ¸öC/S³ÌÐò£¬ÊµÏÖC/SͨÐÅ¡£
¿Í»§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍTimeÃüÁ·þÎñÆ÷¶Ë½ÓÊܵ½¸Ã×Ö·û´®ºó½«·þÎñÆ÷¶Ëµ±Ç°Ê±¼ä·µ»Ø¸ø¿Í»§¶Ë£»¿Í»§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍExitÃüÁ·þÎñÆ÷¶ËÏò¿Í»§¶Ë·µ»Ø“Bye”ºóÍ˳ö¡£
ÌâÄ¿±È½Ï¼òµ¥µÄ£¬ÎÒÃÇÖ±½ÓÀ´¿´´úÂë°É£º
Ê×ÏÈÊÇ·þÎñÆ÷¶ ......