2016-03-10 63 views
0

有沒有辦法做這樣的事情在JSP:表達成JSP:包括

<% String path = session.getAttribute("path").toString(); %> 
<jsp:include page="<%=path%>/vue/includes/header.jsp"/> 

pathlocalhost:8080

感謝,

我有一個錯誤:attribute for %>" is not properly terminated

這裏是代碼:

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<jsp:useBean id="User" class="metier.User"/> 
<jsp:useBean id="Pays" class="metier.Pays"/> 
<jsp:setProperty name="User" property="login" param="login"/> 
<jsp:setProperty name="User" property="pass" param="pass"/> 
<% String path = session.getAttribute("path").toString(); %> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>JSP Page</title> 
    </head> 
    <body> 
     <jsp:include page="<%=path%>/vue/includes/header.jsp"/> 
     <h1>Hello</h1> 
     <c:forEach var="p" items="${Pays.getPays()}"> 
      <a href="<%=path%>/vue/team.jsp?idPays=${p.idPays}"><c:out value="${p.name}"/></a><br/> 
     </c:forEach> 
     <jsp:include page="<%=path%>/vue/includes/footer.jsp"/> 
    </body> 
</html> 

header.jsp僅僅是一個HTML文件

PS:我在JSP

+0

嘗試後所有的代碼 – Abdelhak

+0

什麼是你的header.jsp與用戶一起做? –

+0

@Abdelhak我已經解釋了..希望你能理解我 – ben

回答

0

初學者這應該工作

<% String path = session.getAttribute("path").toString(); 
    String url = "http://" + path + "/vue/includes/header.jsp"; 
%> 
<c:import url='${url}'/> 
+0

不工作:(!我試圖找到一個解決方案,但不工作,你有一個相對鏈接的想法嗎?謝謝 – ben

+0

你嘗試'c:import'語句或'jsp:include'嗎? – MaxZoom