How to create a master page?

强颜欢笑 提交于 2020-07-03 03:49:27

问题


I need to create a master page in JSP to be used by other JSPs for them to have the same look and feel and menus. How can I do that in JSP?


回答1:


You can use either

<%@ include file="/absoluteFragment.jsp" %>

or

<jsp:include page="relativeDynFragment.jsp" />

To know the difference see also http://www.jguru.com/faq/view.jsp?EID=13517:

The <%@include file="abc.jsp"%> directive acts like C "#include", pulling in the text of the included file and compiling it as if it were part of the including file. The included file can be any type (including HTML or text).

The <jsp:include page="abc.jsp"> tag compiles the file as a separate JSP file, and embeds a call to it in the compiled JSP.




回答2:


You can use <jsp:include /> tag or JSP Templates. In case if you are familiar with JSF (JavaServer Faces technology) then use Facelets.



来源:https://stackoverflow.com/questions/7872203/how-to-create-a-master-page

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