JSP templates for Struts2


/ Published in: HTML
Save to your folder(s)

Code snippets to use as a template for consistent HTML page generation


Copy this code and paste it in your HTML
  1. top:
  2.  
  3. <?xml version="1.0" encoding="UTF-8"?>
  4. <jsp:include page="doctype.jsp"/>
  5. <jsp:include page="html.jsp"/>
  6.  
  7. doctype.jsp:
  8.  
  9. <!DOCTYPE html
  10. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  11. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  12.  
  13. html.jsp:
  14.  
  15. <%-- -*- html -*- --%>
  16.  
  17.  
  18. <%@ taglib prefix="s" uri="/struts-tags" %>
  19.  
  20.  
  21. <%-- The template for all web page generation --%>
  22.  
  23. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  24. <jsp:include page="head.jsp"/>
  25. <body id="<s:property value='dom.pageBodyId'/>">
  26. <jsp:include page="nav.jsp" />
  27. <div id="content">
  28. <jsp:include page="contentPreamble.jsp"/>
  29. <jsp:include page="content.jsp"/>
  30. <jsp:include page="footer.jsp"/>
  31. </div>
  32. </body>
  33. </html>
  34.  
  35.  
  36. head.jsp:
  37.  
  38. <%-- -*- html -*- --%>
  39.  
  40.  
  41. <%@ taglib prefix="s" uri="/struts-tags" %>
  42.  
  43.  
  44.  
  45.  
  46. <title><s:text name="title"/></title>
  47.  
  48.  
  49. <meta name="keywords" content="log analysis"/>
  50.  
  51.  
  52. <link rel="stylesheet"
  53. type="text/css"
  54. href="css/dsee.css"
  55. media="screen">
  56.  
  57.  
  58. </head>
  59.  
  60.  
  61. content.jsp:
  62.  
  63. <%-- -*- html -*- --%>
  64.  
  65.  
  66. <%@ taglib prefix="s" uri="/struts-tags" %>
  67.  
  68.  
  69. <s:bean name="packageName.PageKeys" var="pageKeys"/>
  70.  
  71.  
  72. <%--
  73. This page includes the requested content page. Each action
  74. sets the 'pageContent' parameter.
  75. --%>
  76.  
  77.  
  78. <s:if test="pageContent == #pageKeys.mainPageKey">
  79. <jsp:include page="main.jsp"/>
  80. </s:if>
  81.  
  82. <s:elseif test="pageContent == #pageKeys.configPageKey">
  83. <jsp:include page="config.jsp"/>
  84. </s:elseif>
  85.  
  86. <s:elseif test="pageContent == #pageKeys.helpPageKey">
  87. <jsp:include page="help.jsp"/>
  88. </s:elseif>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.