有没有办法在JSP中做这样的事情:
<% String path = session.getAttribute("path").toString(); %>
<jsp:include page="<%=path%>/vue/includes/header.jsp"/>
path
中的有localhost: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 :(得分:0)
这应该有效
<% String path = session.getAttribute("path").toString();
String url = "http://" + path + "/vue/includes/header.jsp";
%>
<c:import url='${url}'/>