JSP·ÖÒ³¼¼ÊõʵÏÖ
title: JSP·ÖÒ³¼¼ÊõʵÏÖ
summary:ʹÓù¤¾ßÀàʵÏÖͨÓ÷ÖÒ³´¦Àí
author: evan_zhao
email: evan_zhao@hotmail.com
¡¡¡¡Ä¿Ç°±È½Ï¹ã·ºÊ¹ÓõķÖÒ³·½Ê½Êǽ«²éѯ½á¹û»º´æÔÚHttpSession»òÓÐ״̬beanÖУ¬·Ò³µÄʱºò´Ó»º´æÖÐÈ¡³öÒ»Ò³Êý¾ÝÏÔʾ¡£ÕâÖÖ·½·¨ÓÐÁ½¸öÖ÷ÒªµÄȱµã£ºÒ»ÊÇÓû§¿ÉÄÜ¿´µ½µÄÊǹýÆÚÊý¾Ý£»¶þÊÇÈç¹ûÊý¾ÝÁ¿·Ç³£´óʱµÚÒ»´Î²éѯ±éÀú½á¹û¼¯»áºÄ·ÑºÜ³¤Ê±¼ä£¬²¢ÇÒ»º´æµÄÊý¾ÝÒ²»áÕ¼ÓôóÁ¿Äڴ棬ЧÂÊÃ÷ÏÔϽµ¡£
¡¡¡¡ÆäËü³£¼ûµÄ·½·¨»¹ÓÐÿ´Î·Ò³¶¼²éѯһ´ÎÊý¾Ý¿â£¬´ÓResultSetÖÐֻȡ³öÒ»Ò³Êý¾Ý£¨Ê¹ÓÃrs.last();rs.getRow()»ñµÃ×ܼƼÌõÊý£¬Ê¹ÓÃrs.absolute()¶¨Î»µ½±¾Ò³Æðʼ¼Ç¼£©¡£ÕâÖÖ·½Ê½ÔÚijЩÊý¾Ý¿â(Èçoracle)µÄJDBCʵÏÖÖв¶àÒ²ÊÇÐèÒª±éÀúËùÓмǼ£¬ÊµÑéÖ¤Ã÷ÔڼǼÊýºÜ´óʱËٶȷdz£Âý¡£
¡¡¡¡ÖÁÓÚ»º´æ½á¹û¼¯ResultSetµÄ·½·¨ÔòÍêÈ«ÊÇÒ»ÖÖ´íÎóµÄ×ö·¨¡£ÒòΪResultSetÔÚStatement»òConnection¹Ø±ÕʱҲ»á±»¹Ø±Õ£¬Èç¹ûҪʹResultSetÓÐЧÊƱس¤Ê±¼äÕ¼ÓÃÊý¾Ý¿âÁ¬½Ó¡£
¡¡¡¡Òò´Ë±È½ÏºÃµÄ·ÖÒ³×ö·¨Ó¦¸ÃÊÇÿ´Î·Ò³µÄʱºòÖ»´ÓÊý¾Ý¿âÀï¼ìË÷Ò³Ãæ´óСµÄ¿éÇøµÄÊý¾Ý¡£ÕâÑùËäȻÿ´Î·Ò³¶¼ÐèÒª²éѯÊý¾Ý¿â£¬µ«²éѯ³öµÄ¼Ç¼ÊýºÜÉÙ£¬ÍøÂç´«ÊäÊý¾ÝÁ¿²»´ó£¬Èç¹ûʹÓÃÁ¬½Ó³Ø¸ü¿ÉÒÔÂÔ¹ý×îºÄʱµÄ½¨Á¢Êý¾Ý¿âÁ¬½Ó¹ý³Ì¡£¶øÔÚÊý¾Ý¿â¶ËÓи÷ÖÖ³ÉÊìµÄÓÅ»¯¼¼ÊõÓÃÓÚÌá¸ß²éѯËٶȣ¬±ÈÔÚÓ¦Ó÷þÎñÆ÷²ã×ö»º´æÓÐЧ¶à ÁË¡£
¡¡¡¡ÔÚoracleÊý¾Ý¿âÖвéѯ½á¹ûµÄÐкÅʹÓÃαÁÐROWNUM±íʾ£¨´Ó1¿ªÊ¼£©¡£ÀýÈç select * from employee where rownum<10 ·µ»ØÇ°10Ìõ¼Ç¼¡£µ«ÒòΪrownumÊÇÔÚ²éѯ֮ºóÅÅÐò֮ǰ¸³ÖµµÄ£¬ËùÒÔ²éѯemployee°´birthdayÅÅÐòµÄµÚ100µ½120Ìõ¼Ç¼Ӧ¸ÃÕâôд£º
[pre] select * from (
select my_table.*, rownum as my_rownum from (
select name, birthday from employee order by birthday
) my_table where rownum <120
) where my_rownum>=
Ïà¹ØÎĵµ£º
get
jsp url ${param.serialID}
action jsp String commentId = ServletActionContext.getRequest().getParameter("commentId");
-- ......
<body>
<%
Cookie[] cookies = request.getCookies() ;
Cookie cookie = null ;
if(cookies!=null){
cookie = cookies[0] ;
out.print("ÉϴηÃÎʵÄipÊÇ£º " + request.getRemoteAddr() +"<br>") ;&n ......
¸÷ÀàÍøÒ³µ¯´°´úÂë±àд
¡¡
¾³£ÉÏÍøµÄÅóÓÑ¿ÉÄܻᵽ¹ýÕâÑùһЩÍøÕ¾£¬Ò»½øÈëÊ×Ò³Á¢¿Ì»áµ¯³öÒ»¸ö´°¿Ú£¬»òÕß°´Ò»¸öÁ¬½Ó»ò°´Å¥µ¯³ö£¬Í¨³£ÔÚÕâ¸ö´°¿ÚÀï»áÏÔʾһЩעÒâÊÂÏî¡¢°æȨÐÅÏ¢¡¢¾¯
¸æ¡¢»¶Ó¹â¹ËÖ®ÀàµÄ»°»òÕß×÷ÕßÏëÒªÌرðÌáʾµÄÐÅÏ¢¡£ÆäʵÖÆ×÷ÕâÑùµÄÒ³ÃæЧ¹û·Ç³£µÄÈÝÒ×£¬Ö»ÒªÍù¸ÃÒ³ÃæµÄHTMLÀï¼ÓÈ뼸¶ÎJavascript´úÂë¼´¿ÉÊ ......
1¡¢Í¨¹ý<s:form
action="ÌøתҳÃæ">Ìá½»Öµ£¬µ«ÊÇÔÚ<s:form>±êÇ©ÖеÄactionºóÃæÖÁ¶àÖ»ÄܸúÒ»¸ö²ÎÊý£¬²¢ÇÒ»¹»á±¨¾¯¸æ£¬ËùÒÔÈç¹û
Ïë´«µÝ²ÎÊý¿ÉÒÔÓÃ<s:hidden name=""
values="username"></s:hidden>À´´«Öµ£¬µ«ÊÇÕý¹æµÄд·¨ÐèÒªÅäºÏ<s:set>±êÇ©À´ÓÃ
È磺
......
½ñÌìÓÖÓöµ½ÂÒÂëÎÊÌâ,¿ÉÕæ·³.ΪʲôTOMCAT¾Í²»ÄÜ×Ô¶¯ÅжÏÏîÄ¿µÄ±àÂë,¶øÒ»¶¨ÒªÏîÄ¿×ñÑTOMCATµÄ±àÂë.
˵˵½â¾ö·½·¨°É:
ÔÚTOMCATµÄSERVER.XMLÅäÖÃÎļþÖеÄconnectorÖÐÌí¼ÓURIEncoding="UTF-8"ÊôÐÔ,Èç
<Connector port="88" maxHttpHeaderSize="8192" maxThreads="20" minSpareThreads="5" maxSpareThreads="10"
e ......