JSP 指令和動作

來源:互聯網
上載者:User

標籤:style   java   color   使用   檔案   art   

JSP中的指令包括:page、include、taglib。
1.page指令:<%@ page %>
page指令提供JSP頁面的屬性,其中定義的屬性適合當前JSP頁面及所有通過include指令或者<jsp:include>動作包含的靜態檔案,但是不適用於動態檔案。
例:<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

2.include指令:<%@ include %>
include指令的作用是把JSP程式、HTML網頁檔案或其他文字檔嵌入到當前的JSP網頁中,這個包含過程是靜態,即靜態包含一個物理檔案。包含的檔案內容可以被JSP解析,這種解析發生在編譯期間。

3.taglib指令:<%@ taglib %>
taglib指令用來定義一個網頁標記及自訂的網頁標記首碼,它使使用者能夠自訂標籤。

JSP中的動作元素包括:include、forward、useBean、getProperty、setProperty、plugin、param。
1.include動作
<jsp:include>標籤用來包含一個靜態或者動態檔案。
例:<jsp:include page="/system/layout/top.jsp"></jsp:include>
2.forward動作
<jsp:forward>標籤用來重新導向一個靜態HTML檔案、JSP檔案或者是一個程式段。
3.useBean動作
<jsp:useBean>標籤用來在JSP頁面中建立一個Bean執行個體,並指定其名稱和作用範圍。
4.getProperty動作
<jsp:getProperty>標籤用來擷取Bean的屬性值(在此之前必須用<jsp:useBean>建立它),並將之轉化為一個字串,然後將其插入到輸出的頁面中。
5.setProperty動作
<jsp:setProperty>標籤表示用來設定Bean中的屬性值。
6.plugin動作
<jsp:plugin>標籤用於在瀏覽器中播放或顯示一個對象(典型為applet和Bean),這種顯示需要在瀏覽器上安裝Java外掛程式。當JSP檔案被編譯後送往瀏覽器時,<jsp:plugin>元素將會根據瀏覽器的版本替換成<object>或者<embed>元素。
7.param動作
<jsp:param>標籤用來傳遞參數,必須與forward、include及plugin動作配合使用。

==========================================================
top.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><%String path = request.getContextPath();%><!--架構必需start--><script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script><script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script><script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script><link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet"type="text/css" /><link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/" /><link rel="stylesheet" type="text/css" id="customSkin" />

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.