jspÖÐÈÕÆÚ´¦Àí
ÈÕÆÚÎÊÌâ
1¡¢»ñÈ¡·þÎñÆ÷¶Ëµ±Ç°ÈÕÆÚ£º
<%@ page import="java.util.Date"%>
<%
Date myDate = new Date();
%>
2¡¢»ñÈ¡µ±Ç°Äê¡¢Ô¡¢ÈÕ£º
<%@ page import="java.util.Date"%>
<%
Date myDate = new Date();
int thisYear = myDate.getYear() + 1900;//thisYear = 2003
int thisMonth = myDate.getMonth() + 1;//thisMonth = 5
int thisDate = myDate.getDate();//thisDate = 30
%>
3¡¢°´±¾µØʱÇøÊä³öµ±Ç°ÈÕÆÚ
<%@ page import="java.util.Date"%>
<%
Date myDate = new Date();
out.println(myDate.toLocaleString());
%>
Êä³ö½á¹ûΪ£º
2003-5-30
4¡¢»ñÈ¡Êý¾Ý¿âÖÐ×Ö¶ÎÃûΪ”publish_time“¡¢ÀàÐÍΪDatetimeµÄÖµ
<%@ page import="java.util.Date"%>
<%
...Á¬½ÓÊý¾Ý¿â...
ResultSet rs = ...
Date sDate = rs.getDate("publish_time");
%>
[code]
5¡¢°´ÕÕÖ¸¶¨¸ñʽ´òÓ¡ÈÕÆÚ
[code]
<%@ page import="java.util.Date"%>
<%@ page import="java.text.DateFormat"%>
<%
Date dNow = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
out.println("It is " + formatter.format(dNow));
%>
Êä³öµÄ½á¹ûΪ£º
It is ÐÇÆÚÎå 2003.05.30 at 11:30:46 ÉÏÎç CST
(¸üΪÏ꾡µÄ¸ñʽ·ûºÅÇë²Î¿´SimpleDateFormatÀà)
6¡¢½«×Ö·û´®×ª»»ÎªÈÕÆÚ
<%@ page import="java.util.Date"%>
<%@ page import="java.text.DateFormat"%>
<%
String input = "1222-11-11";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date t = null;
try{
t = formatter.parse(input);
out.println(t);
}catch(ParseException e){
out.println("unparseable using " + formatter);
}
%>
Êä³ö½á¹ûΪ£º
Fri Nov 11 00:00:00 CST 1222
7¡¢¼ÆËãÈÕÆÚÖ®¼äµÄ¼ä¸ô
<%@ page import="java.util.Date"%>
<%@ page import="java.text.DateFormat"%>
<%
String input = "2003-05-01";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date d1 = null;
try{
d1 = formatter.parse(input);
}catch(ParseException e){
out.println("unparseable using " + formatter);
}
Date d2 = new Date();
long diff = d2.getTime() - d
Ïà¹ØÎĵµ£º
required ÊÇÊÇ·ñΪ±ØÑ¡ÊôÐÔ
rtexprvalueµÄÈ«³ÆÊÇ Run-time Expression Value£¬ ËüÓÃÓÚ±íʾÊÇ·ñ¿ÉÒÔʹÓÃJSP±í´ïʽ.
µ±ÔÚ<attribute>±êÇ©ÀïÖ¸¶¨<rtexprvalue>true</rtexprvalue>ʱ£¬ ±íʾ¸Ã×Ô¶¨Òå±êÇ©µÄijÊôÐÔµÄÖµ¿ÉÒÔÖ±½ÓÖ¸¶¨»òÕßͨ¹ý¶¯Ì¬¼ÆËãÖ¸¶¨, example as follow:
<sql:query var="result" & ......
java web¿ª·¢ÖУ¬ÈçºÎ²é¿´JSPºÍServlet°æ±¾
2008-12-10 09:00
ÎÒÃÇÔÚjava web¿ª·¢µÄ¹ý³ÌÖУ¬ÓÐʱÔÚ×ÊÁÏÉÏ¿ÉÄÜ»áÌáµ½»·¾³ËùÒªÖ§³ÖµÄJSP£¬Servlet°æ±¾¡£Èç¹û°æ±¾µÍ¾Í¿ÉÄܳöÏÖ²âÊÔ´íÎó¡£
·½·¨£º´ò¿ªtomcatµÄcommon\lib Ŀ¼Ï£¬ÓÐÁ½¸öJARÎļþ£º jsp-api.jar servlet-api.jar ¡£Èç¹ûûÓУ¬ÄÇ¿ÉÄÜÊÇÄãûÓÐÌí¼Ó½øÀ´¡£½âѹÕâÁ½¸ ......
ÏîÄ¿¿ò¼ÜS2SH,jspÒ³ÃæÈçÏ£¬selectÁбíÉèΪmultiple¡£ÎªÁËÄÜÔÚactionÀïÈ¡µ½Ç°Ì¨½çÃæselectÁбíµÄ¶àÑ¡Öµ£¬Ï¹¸ãÁËÁ½Ì죬½ñÌìÖÕÓڳɹ¦¡£Æäʵºǫ́actionȡǰ̨jspÒ³ÃæµÄÖµºÜ¼òµ¥£¬·Ï»°²»¶à˵£¬ÏÈÌù´úÂ룺
<body>
<form action="sendMsg.action?senderId=${users.id }&username=${users.username}" m ......
ServletÈý¸öÒªËØ:
1.±ØÐë¼Ì³Ð×ÔHttpServlet
2.±ØÐëʵÏÖdoGet()»òÕßdoPost()
3.±ØÐëÔÚweb.xmlÖÐÅäÖÃServlet
<servlet>
<servlet-name> </servlet-name>
<servlet-class> </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> </servlet-nam ......
ÒÔÏÂΪÔÚjspÒ³ÃæjavascriptʵÏÖ·½Ê½£º
Èç¹ûÐèÒªÉèÖõØÖ·¹©Óû§ÏÂÔØʹÓÃ
1. ÐèÒªµ¼ÈëjspSmartUpload.jar°ü¡£
2. ÔÚÒ³ÃæÌí¼Ó<%@ page import=”com..jspsmart.upload.*”%>
function createOCX()
{
try
{
//´´½¨ActiveXobject¶ÔÏóʱ´«Èë²å¼þµÄVersionIndependProgID
//´Ë´¦ÅжÏϵͳÖÐÊÇ·ñ°²×°meid ......