![](/img/trans.png)
[英]Google App Engine (Java) - Redirection to jsp from web.xml
[英]Java web application global parameters from web.xml in jsp
如何從web.xml中檢索參數/變量htmlRootPath
並將其注入我的頭jsp模板(見下文)? 目前我使用的是initialize.jsp
包含文件並且它可以工作,但是想知道我是否可以在web.xml文件中使用它。 我已經閱讀過在Servlet中使用web.xml但是如何在jsp中進行操作。
----這就是我現在這樣做的方式。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="inc_taglibs.jsp" %>
<%@ include file="inc_initialize.jsp" %>
<html>
<head>
<title>D463 - Solid Mechanics - [<c:out value="${dbTable.strTableTitle}" />] <c:out value="${param.pageTitle}" /></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<c:out value="${htmlRootPath}"/>/css/styleScreen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="<c:out value="${htmlRootPath}"/>/css/stylePrint.css" media="print" />
<link rel="stylesheet" type="text/css" href="<c:out value="${htmlRootPath}"/>/css/cssmenu.css" media="all"/>
<link rel="stylesheet" type="text/css" href="<c:out value="${htmlRootPath}"/>/css/calendarPOP.css" media="all"/>
<script type='text/javascript' src='<c:out value="${htmlRootPath}"/>/javascript/calendar_popup.js'></script>
<script type='text/javascript' src='<c:out value="${htmlRootPath}"/>/javascript/collapse.js'></script>
<script type='text/javascript' src='<c:out value="${htmlRootPath}"/>/javascript/sorttable.js'></script>
<script type='text/javascript' src='<c:out value="${htmlRootPath}"/>/javascript/window_popup.js'></script>
<script type='text/javascript' src='<c:out value="${htmlRootPath}"/>/javascript/switchLogin.js'></script>
</head>
編輯:我想傳遞htmlRootPath的原因是因為這是我用於我開發的每個應用程序的頭模板。 它為我的同事在公司徽標,導航,布局等方面使用的應用程序提供了一致的感覺......
我們的Configuration Management組控制生產中的源代碼(jsp,java),但不控制HTML。
所以我的webapp文件夾在生產中不受限制。 但是,如果我想修改我的CSS文件怎么辦? 我沒有在上面顯示,但是我使用<c:import
來查找位於web app文件夾之外的navaigation菜單。 這樣,我可以添加一個新的鏈接到我的導航,而無需通過CM變更請求流程(文書工作和簽名!yuk)
由於此標頭是我用於許多不同應用程序的模板文本,因此我只需要編輯每個特定Web應用程序ONCE的此非配置控制文件夾的路徑。
上下文范圍的初始化參數<context-param>
是${initParam}
可用的Map
。
所以:
${initParam.htmlRootPath}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.