簡體   English   中英

jsp:include中的Taglib繼承

[英]Taglib inheritance in jsp:include

是否可以從父JSP的“后代”繼承taglib或導入?

我舉個例子

header.jsp

<%@ page contentType="text/html" isELIgnored="false"
     import="org.something.utils.Constants"%>

//some code, Constants class is available here

index.jsp

<jsp:include page="template/header.jsp" />
//Constants is not available, I get a JasperException: Unable to compile class for JSP

同樣,taglibs繼承似乎不起作用。 那么有沒有辦法使這項工作呢?

Taglib和導入不會被繼承,並且標記中的所有內容也不能被繼承或通過頁面傳遞(JspContext和request屬性除外)。

您在這里有兩個選擇:

  1. 在您擁有的每個JSP中進行導入。
  2. 使通用的類和庫成為全局類和庫,這取決於IDE和您正在運行的服務器。

編輯定義JSP隱式包括:

  1. 對於Netbeans http://docs.oracle.com/cd/E19575-01/819-3669/bnajl/index.html
  2. 全球教程http://sabahmyrsh.blogspot.com/2009/06/jsp-defining-implicit-includes.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM