日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

精講jsp基礎(chǔ)教程_JSP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:解析如何在JSP中使用Spring
在JSP中使用Spring其實很容易,主要用到Spring的WebApplicationContextUtils.getWebApplicationContext函數(shù)。 要再JSP里面得到ApplicationContext需要這么做. 首先 import=org.springframework.web.context.support.*,org.springframework.context.* 然后可

jsp中Servlet的三個要素:
1.必須繼承自HttpServlet
2.必須實現(xiàn)doGet()或者doPost()
3.必須在web.xml中配置Servlet
<servlet>
<servlet-name> </servlet-name>
<servlet-class> </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> </servlet-name>
<url-pattern> </url-pattern>
</servelt-mapping>

HttpServeltRrequest:請求對象
getParameter():獲得表單元素的值
getAttribute():獲得request范圍中的屬性值
setAttribute():設(shè)置reqeust范圍中的屬性值
setCharacterEncoding():設(shè)置字符編碼

HttpSerletResponse:相應(yīng)對象
sendRedirect():外部跳轉(zhuǎn)
getWriter():獲得輸出流對象
setContentType("text/html; charset=utf-8"):設(shè)置相應(yīng)內(nèi)容格式和編碼

四種會話跟蹤方式:
1.Session
HttpSession session = request.getSession();
session.setAttribute("name", "zhangsan");
session.setAttribute("pwd", "aaa");
String name = (String) session.getAttribute("name");

2.cookie:
//創(chuàng)建Cookie
Cookie cookie = new Cookie("name", "zhangsan");
//設(shè)置Cookie的超時時間
cookie.setMaxAge(24 * 60 * 60 *60);
//把Cookie發(fā)送到客戶端
response.addCookie(cookie);

//得到客戶端發(fā)送的Cookie
Cookie [] cookies = request.getCookies();
for(int i=0; i <cookies.length; i++) {
  Cookie temp = cookies[i];
  String key = temp.getName();
  String value = temp.getValue();
}

3.隱藏表單域
<input type="hidden" name="name" value="zhangsan" />
request.getParameter("name");

4.Url重寫
問號傳參
LoginServlet?username=zhangsan&pwd=123
String name = request.getParameter("username");
String pwd =request.getPareameter("pwd");

內(nèi)部跳轉(zhuǎn):
LoginServlet
request.getRequestDispatcher("index.jsp").forward(request, resposne);
外部跳轉(zhuǎn):
response.sendRedirect("index.jsp");
內(nèi)部跳轉(zhuǎn)是一次請求和一次響應(yīng)
外部跳轉(zhuǎn)是兩次請求和兩次響應(yīng)

ServletContext:Servlet上下文對象
它是一個公共區(qū)域,可以被所有的客戶端共享
setAttribute():向公共區(qū)域里放入數(shù)據(jù)
getAttribute():從公共區(qū)域里取數(shù)據(jù)

二:
三:三個標(biāo)準(zhǔn)范圍:request, session, ServletContext
  共同點:都有setAttribute(), getAttribute()
  區(qū)別:范圍不同,request < session < servletContext
四:四種會話跟蹤方式
五:服務(wù)器上的五大對象
  request, response, servlet, session, servletContext
 
Jsp:Java Server Page
頁面構(gòu)成:7種元素
1.靜態(tài)內(nèi)容:html
2.指令:page, include, taglib:
<%@ 指令名 屬性1="屬性值1" 屬性2="屬性值2" %>
3.表達(dá)式: <%=表達(dá)式 %>
4.Scriptlet <% Java代碼 %>
5.聲明: <%! %>:變量和方法
6.動作: <jsp:動作名 屬性="屬性值"> </jsp:動作名>
7.注釋:
客戶端看不到的: <%-- --%>
客戶端可以看到的: <!-- -->


Jsp的執(zhí)行過程:
1.轉(zhuǎn)譯:Jsp--->Servlet
2.編譯:Servlet---->.class
3.執(zhí)行:.class
第一次訪問jsp的時候響應(yīng)速度較慢,后面請求時響應(yīng)速度快

腳本:
表達(dá)式: <%= %>
Scriptlet: <% %>
聲明: <%! %>

指令:
page:language, import, errorPage, isErrorpage
include:file
taglib:uri:指定標(biāo)簽庫描述符的路徑 prefix:指定標(biāo)簽的前綴

分享:詳解Java編程--基礎(chǔ)代碼的規(guī)范化
命名規(guī)范 定義這個規(guī)范的目的是讓項目中所有的文檔都看起來像一個人寫的,增加可讀性,減少項目組中因為換人而帶來的損失。(這些規(guī)范并不是一定要絕對遵守,但是一定要讓程序有良好的可讀性) Package的命名 Package的名字應(yīng)該都是由一個小寫單詞組成。 Cla

共3頁上一頁123下一頁
來源:模板無憂//所屬分類:JSP教程/更新時間:2010-01-31
相關(guān)JSP教程