Reputation: 1318
I have a Spring + Apache Tiles 3 Aplication.
I have a layout and inside of this, the header, the body and the footer:
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>
The "${pageContext.request.contextPath}" works fine inside the Layout, but not on the JSP children's:
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>
This prints the "${pageContext.request.contextPath}" "as is" in the result HTML.
Upvotes: 0
Views: 1532
Reputation: 11
Try to use <%@ page isELIgnored="false" %>
. It will solve your problem
Upvotes: 1
Reputation: 2835
Since you mentioned HTML code and say that the context path is printed "as-is", is this code in HTML file? Then it will not work.
Check this question - ${pageContext.request.contextPath} is not working on plain HTML
Upvotes: 0