在开发过程中,有些功能是一直可以重复使用的,这样的页面我们可以做成公共的,供每个页面适用,那么就需要我们在使用的时候做一下嵌套。
例如:这样一个页面中:
上半部分是公共的:
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%@ taglib prefix="fund" uri="/WEB-INF/tag/fund.tld"%>
<div class='box-content box-double-padding'>
<form class='form form-horizontal' id="selectForm" action="${pageContext.request.contextPath}/admin/trade/payByCard" method="post" style='margin-bottom: 0;'>
<input id="urlParam" name="urlParam" type='hidden' value="${param.pageTitle}" />
<div class='row-fluid'>
<div class="span6 box">
<label class='control-label'>客户类型</label>
<div class='controls'>
<span class="control-text">
<select class='input-block-level' id='custType' name="custType" validate="required:true">
<fund:dictOptions dictId="301001" value="${ map['custType'] }"/>
</select>
<i class="form-tips text-error">*</i>
</span>
</div>
</div>
<div class="span6 box">
<label class='control-label'>资金卡号</label>
<fund:appParam keyName="pay_mode" keyValue="2">
<div class='controls'>
<input class="form-control" id="accNo" name="accNo" autocomplete="off" value="${map['accNo']}" type='text' validate="required:true"/>
<i class="form-tips text-error">*</i>
</div>
</fund:appParam>
<div class='controls'>
<button class='btn btn-default' id="selectBtn" mode='submit' type='submit'>刷卡</button>
</div>
</div>
</div>
<div class='row-fluid'>
<div class="span6 box">
<label class='control-label'>基金交易账户</label>
<div class='controls'>
<input class="form-control" id="financeAcc" name="financeAcc" autocomplete="off" value="${map['financeAcc']}" type='text' disabled/>
</div>
</div>
<div class="span6 box">
<label class='control-label'>风险等级</label>
<div class='controls'>
<%-- <select class='input-block-level' id='riskLevel' ajaxValue="${riskLevel}" name="riskLevel"> --%>
<%-- <fund:dictOptions dictId="301005" value="${map['riskLevel']}"/> --%>
<!-- </select> -->
<input class="form-control" id="riskLevel" name="riskLevel" autocomplete="off" value="${map['riskLevel']}" type='text' disabled/>
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript">
</script>
在另一个 页面嵌套的时候只需要把页面加进去就可以了:
<jsp:include page="../../includes/tradeCommon.jsp" flush="true" ></jsp:include>
这样,就实现了一个jsp页面嵌套公共的jsp页面。