再web开发的过程中,往往head.jsp是单独抽出来的,但是有时候可能会有根据配置动态include不同页面的需求,怎么做呢,如下:
<jsp:include page="${empty pageContext.servletContext.getAttribute('index') ? 'footer.jsp': '../footer_'.concat(pageContext.servletContext.getAttribute('index')).concat('.jsp')}"></jsp:include>
说明 :
pageContext.servletContext.getAttribute('index')得到我们放在域里面的配置属性,根据这个配置的不同加载不同的jsp文件,完美解决需求