2016-06-22 13 views
0

Ich habe eine Spring + Apache Tiles 3 Anwendung.request.contextPath nicht in Apache Tiles JSP-Fragmente

Ich habe ein Layout und innerhalb dieser, der Kopf, der Körper und der Fußzeile:

defaultLayout.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<%@ page isELIgnored="false" %> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %> 

<html> 

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
    <title><tiles:getAsString name="title" /></title> 
    <link href="<c:url value='/static/css/bootstrap.css' />" rel="stylesheet"></link> 
    <link href="<c:url value='/static/css/app.css' />" rel="stylesheet"></link> 
</head> 

<body> 
     <header id="header"> 
      Web Application Context Path="${pageContext.request.contextPath}" 
      <tiles:insertAttribute name="header" /> 
     </header> 

     <section id="sidemenu"> 
      <tiles:insertAttribute name="menu" /> 
     </section> 

     <section id="site-content"> 
      <tiles:insertAttribute name="body" /> 
     </section> 

     <footer id="footer"> 
      <tiles:insertAttribute name="footer" /> 
     </footer> 
</body> 
</html> 

Die "$ {pageContext.request.contextPath}" arbeitet innerhalb Fein das Layout aber nicht auf den JSP Kinder:

menu.jsp

<nav> 
<a href="${pageContext.request.contextPath}/"><img class="logo" src="${pageContext.request.contextPath}/static/img/Linux-icon.png"></a> 
<ul id="menu"> 
    <li><a href="${pageContext.request.contextPath}/">Home</a></li> 
    <li><a href="${pageContext.request.contextPath}/products">Products</a></li> 
    <li><a href="${pageContext.request.contextPath}/contactus">Contact Us</a></li> 
</ul> 

Dies druckt die "$ {pageContext.request.contextPath}" "wie sie sind" im Ergebnis HTML.

Antwort

0

Da Sie HTML-Code erwähnt und sagen, dass der Kontextpfad "wie-ist" gedruckt wird, ist dieser Code in HTML-Datei? Dann wird es nicht funktionieren.

prüfen diese Frage - ${pageContext.request.contextPath} is not working on plain HTML

+0

Nein, der Code ist in einer JSP-Datei. – Ildelian

+0

Verweisen - http://stackoverflow.com/questions/2168832/expression-language-in-jsp-not-working –

0

Try <%@ page isELIgnored="false" %> zu verwenden. Es löst Ihr Problem