Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JSPÊý¾Ý¿âÁ¬½Ó´óÈ«

JSPÊý¾Ý¿âÁ¬½Ó´óÈ«
2008-07-22 11:47
Ò»¡¢jspÁ¬½ÓOracle8/8i/9iÊý¾Ý¿â£¨ÓÃthinģʽ£©
testoracle.jspÈçÏ£º
< %@ page contentType="text/html;charset=gb2312"% >
< %@ page import="java.sql.*"% >
< html >
< body >
< %Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orclΪÄãµÄÊý¾Ý¿âµÄSID
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {% >
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º< %=rs.getString(1)% >
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º< %=rs.getString(2)% >
< %}% >
< %out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");% >
< %rs.close();
stmt.close();
conn.close();
% >
< /body >
< /html >
¶þ¡¢jspÁ¬½ÓSql Server7.0/2000Êý¾Ý¿â
testsqlserver.jspÈçÏ£º
< %@ page contentType="text/html;charset=gb2312"% >
< %@ page import="java.sql.*"% >
< html >
< body >
< %Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
//pubsΪÄãµÄÊý¾Ý¿âµÄ
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {% >
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º< %=rs.getString(1)% >
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º< %=rs.getString(2)% >
< %}% >
< %out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");% >
< %rs.close();
stmt.close();
conn.close();
% >
< /body >
< /html >
Èý¡¢jspÁ¬½ÓDB2Êý¾Ý¿â
testdb2.jspÈçÏ£º
< %@ page c


Ïà¹ØÎĵµ£º

JSPÒ³Ãæ²ãµÄ¾­Ñ鱸Íü×ܽá

 1£º²éÕÒÒ³ÃæµÄ´úÂë´íÎóÓÌÈçÒ½Éú¸ø²¡ÈË¿´²¡£¬²»ÄÜͷʹҽͷ£¬½ÅÍ´Ò½½Å£¬¾ÍÊÇ˵һ¸öµØ·½µÄ“´íÎó”ÍùÍùÊÇÓɱðµÄµØ·½ÓÐÎÊÌâ¶øÒý·¢µÄ¡£
2£ºÈç¹ûÊý¾Ý·ÅÔÚrequestÖÐ(¿ÉÄÜ°üÀ¨url²ÎÊý)£¬ÄÇôҪÔÚºóÐøµÄÒ³Ãæ(»òÊÇˢкó)Öп´µ½ÒÔÇ°µÄÊý¾Ý¿ÉÒÔʹÓÃ${param.yourdate},²»¹ý·ÅÔÚActionFormÖпÉÄܸüºÃһЩ¡£
3£ºÔÚJSPÒ³ ......

JSPÂÒÂëÖÕ¼«½â¾ö£¨ÊµÓã©

 JspÊÇÒ»¸öºÜÈÈÃŵĻ°Ì⣬µ«Èôó¶àÊýÈ˶¼Í·Í´µÄÊÇJSPÒ³ÃæÖеÄÂÒÂëÎÊÌ⣬±ÊÕßÉíÓÐÌå»á£»ÔøΪÁ˽â¾öÖÐÎÄÂÒÂëÎÊÌâÓôÃÆÁ˺ü¸Ì죬ÊÔÁ˺ܶ෽·¨¶¼²»ÐС£×îºóÔÚJSPרҵÈËÊ¿µÄ°ïÖúÏ£¬ÖÕÓÚ½â¾ö¡£Ö®ºó±ÊÕßÔø¶Ô´Ë×öÁËһЩСµÄÑо¿¡£  
  Ê×ÏÈÎÒÃÇÏÈÁ˽âÒ»ÏÂÎÊÌâµÄÔ­Òò¡£Ò»°ãÇé¿öÔÚÔÚÿ¸öJSPÒ³µÄÍ·²¿¶¼ÓÐÕâÑùÒ» ......

ÀûÓÃJSP£¬·ÀÖ¹Öظ´Ìá½»µÄÎÊÌâ

    Ò»°ã£¬ÔںܶàÓ¦ÓÃϵͳÖУ¬Óû§¶à´ÎÌá½»Öظ´Êý¾ÝÊÇÒ»¸öºÜÑÏÖصÄÎÊÌ⣬»áµ¼ÖÂÓ¦ÓÃϵͳÖкܶàÀ¬»øÊý¾Ý£¬ÔÚStrutsÖпò¼ÜÖУ¬ÓÐTOKEN»úÖÆÀ´·ÀÖ¹Óû§Ìá½»Öظ´Êý¾Ý£¬ÕâÊÇÒ»¸öºÜºÃµÄ°ì·¨£¬µ«ÊÇ£¬TOKEN»úÖƱØÐëµÃÓõ½html:form±êÇ©£¬ÎÒ²»Ï²»¶ÓÃÕâ¸ö±êÇ©£¬ÎÒ¾õµÃÊÇÒ»¸öÀÛ׸£¬ËùÒÔÎÒÈ¥µôHTML:FORM±êÇ©£¬ÖØж¨ÒåTOK ......

jsp½ûÖ¹Ò³Ã滺´æ

1.½ûÖ¹¿Í»§¶Ë»º´æÒªÔÚ<head>ÖмÓÈëÀàËÆÈçÏÂÄÚÈÝ£º
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
2.ÔÚ·þÎñÆ÷µÄ¶¯Ì¬ÍøÒ³ÖнûÖ¹»º´æ£¬Òª¼ÓÈëÀàË ......

jspÒ³Ãæ»ñÈ¡Action±äÁ¿Öµ(²»Í¨¹ý±êÇ©)


¹Ø¼ü×Ö: struts2 webwork
½ñÌìÓöµ½Ò»¸öÇé¿ö,ÒªÔÚjspÒ³ÃæÉÏ´¦Àí²éѯ³öÀ´listÒ³µÄһЩÊý¾Ý,¸Ä±äActionÀàÌ«Âé·³,ÓÚÊÇÏëµ½´ÓÒ³ÃæÉÏÖ±½Ó»ñÈ¡ActionÖеıäÁ¿Öµ,²¢½øÐвÙ×÷,ÏÖÔÚ°Ñ»ñÈ¡·½·¨¼Ç¼һÏÂ,ÒÔ±ãÒÔºó²éѯ.
Èç¹ûÔÚActionÀàÀïÓÐÒ»¸ö¼òµ¥µÄ±äÁ¿,²¢ÇÒÒѾ­Ð´ºÃÁËËüµÄgetºÍset·½·¨
private String test="jsp  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ