Is it possible to have a dynamic path as part of a jsp include

风流意气都作罢 提交于 2019-12-10 10:34:39

问题


I have a include file in my jsp

    <%@ include file = "includes/testinclude1.jsp" %>

Test Include1 contains struts tags, and therefore needs to be pulled in and compiled. Which works ok. Is there a way to make the path for this file be dynamic in any way or am I looking at a rethink in terms of design?


回答1:


You can the <jsp:include page="..."> tag instead of the static <%@ include %> which only works for static references.




回答2:


For anyone that is curious, I used a struts include tag, based on artbristols answer and managed to make it dynamic with OGNL. Thanks for all your input.

<s:include value="includes/templates/%{post.template.name}.jsp" />



回答3:


yes

<%
    String usuarioTipo = uDTO.getNombreGrupo().toLowerCase();
    String menu = "../WEB-INF/../jspf/".concat(usuarioTipo).concat("/menu.jspf");
%>
<jsp:include page ="<%=menu%>"/>


来源:https://stackoverflow.com/questions/8092386/is-it-possible-to-have-a-dynamic-path-as-part-of-a-jsp-include

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!