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

JSPÖеIJÎÊý´«µÝ·½·¨

£¨1£©ÀûÓÃ<jsp:param name="paramName" value="paramValue"></jsp:param>ÆäÖÐnameΪÓëÊôÐÔÏà¹ØÁªµÄ¹Ø¼ü´Ê£¬valueΪÊôÐÔµÄÖµ¡£
    ʾÀý£º´«³£Á¿×Ö·û´®<param name="userName" value="shilei"/>
    ʾÀý£º´«±äÁ¿ User user=new User("shilei");//UserÊÇÒ»¸öÀà
    <jsp:param name="user" value="<%=user%>"/>//<%=user%>ÀïÃæÀ¨ÆðÀ´µÄÊÇjsp±í´ïʽ
 
£¨2£©ÀûÓÃsession.setAttribute("attributeName",attribute)»òÕßrequest.setAttribute("attributeName",attribute)
    ʾÀý£ºUser user=new User("shilei");
    session.setAttribute("userName",user);
 
£¨3£©¾ÍÏñ´«Í³µÄhtmlÄÇÑùÀûÓÃ±íµ¥×¨µÝ²ÎÊý¡£
    ʾÀý£º<form name="loginForm" action="checkLogin.jsp" method="get">
               <input type="text" name="username">
               <input type="password" name="userpwd">
               <input type="submit" value="Ìá½»">
             </form>
 
£¨4£©Ö±½Ó¹ÒÔÚURLºóÃæ¡£Ê¾Àý£ºresponse.sendRedirect("checkLogin.jsp?username="+username+"&userpwd="+userpwd"");
String name=request.getParameter("name");
<a href="welcome.jsp?name=<%=name%>">
 
£¨5£©ÀûÓÃcookie¶ÔÏóÀ´´«µÝ
Cookie cookie=new Cookie("my","liuliu")
cookie.setMaxage(60*60);(ÒÔÃëΪµ¥Î»)×î´óµÄÉúÃüÖÜÆÚ
response.addCookie(cookie);
Cookie[] cookies=request.getCookies();(¿ÉÒÔͨ¹ý±éÀú´ËÊý×éÀ´·ÃÎÊÖµ)


Ïà¹ØÎĵµ£º

JSP»·¾³ÅäÖÃ

Ò») °²×°JDK(jdk-1_5_0-windows-i586.exe)£¬Ä¬Èϰ²×°£»
(¶þ) °²×°Tomcat(tomcat5.5-installer.exe)£¬Ä¬Èϰ²×°£»
 * ˳Ðò²»¿ÉÒԵߵ¹ *
(Èý) ²âÊÔ°²×°½á¹û
1. ´ò¿ªä¯ÀÀÆ÷ÊäÈëhttp://localhost:8080£¬Èç¹û³É¹¦£¬Ôò»á¿´µ½»¶Ó­Ò³Ãæ¡£´Ëʱ·ÃÎʵÄ·¾¶Îª$tomcat/webapps/root/
(ËÄ) ½¨Á¢ÎÒµÄÕ¾µ ......

JSPʵÀýÈý¡¢sql·ÖÒ³(1)

index.jsp
<%@ page language="java" import="java.sql.*" import="java.lang.*" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%!
& ......

Jsp±àÂë¹æ·¶


Jsp±àÂë¹æ·¶
1.1 Îļþºó׺(File Suffixes)
ÎļþÀà±ð ¡¡¡¡ ¡¡¡¡¡¡¡¡¡¡Îļþºó׺
--------------------------------------
JavaÔ´Îļþ¡¡¡¡¡¡¡¡¡¡¡¡¡¡.java
Java×Ö½ÚÂëÎļþ¡¡¡¡¡¡¡¡¡¡.class
¶¯Ì¬Ò³Ãæ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡.jsp
¾²Ì¬Ò³Ãæ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡.html
½Å±¾Îļþ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡.js
1.2 ³£ÓÃÎļþÃû(Common ......

JSPÁôÑÔ¹ÜÀíϵͳ (¸½¼ÓÓû§È¨ÏÞ¹¦ÄÜ)

JSPÁôÑÔ¹ÜÀíϵͳ (¸½¼ÓÓû§È¨ÏÞ¹¦ÄÜ)
1.ÓοͿÉÒԲ鿴ͨ¹ýÉóºËµÄÁôÑÔ£»
2.ÆÕͨÓû§µÇ¼ºó¿ÉÒÔ·¢±íÁôÑÔ£¬ÐÞ¸ÄÃÜÂ룻
3.¹ÜÀíÔ±µÇ¼ºó¿ÉÒÔÉóºË¡¢Ð޸ġ¢É¾³ýÁôÑÔ£»
4.³¬¼¶¹ÜÀíÔ±µÇ¼ºó¿ÉÒÔ¹ÜÀíÓû§£¬É¾³ýÓû§¡¢ÐÞ¸ÄÃÜÂë¡¢¸ü¸ÄȨÏÞ¡£
´ËÁôÑÔ¹ÜÀíϵͳ°üº¬ÒÔÏÂÎļþ£º
1.Ê×Ò³(index.jsp)£º°´·¢±íʱ¼äµ¹ÐòÏÔʾÁôÑÔÄÚÈÝ£¬²»Í¬È¨ ......

JSP Òþʽ¶ÔÏó

·pageContext£ºÌṩ¶ÔÒ³ÃæÊôÐԵķÃÎÊ¡£
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
pageContext.setAttribute("basePath",basePath);
%>
ʹÓãº
${pageScope}
 
·reques ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ