JSP tricks to make templating easier?

前端 未结 7 815
猫巷女王i
猫巷女王i 2020-11-22 08:41

At work I\'ve been tasked with turning a bunch of HTML files into a simple JSP project. It\'s really all static, no serverside logic to program. I

7条回答
  •  一向
    一向 (楼主)
    2020-11-22 09:29

    I made quite easy, Django style JSP Template inheritance tag library. https://github.com/kwon37xi/jsp-template-inheritance

    I think it make easy to manage layouts without learning curve.

    example code :

    base.jsp : layout

    <%@page contentType="text/html; charset=UTF-8" %>
    <%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%>
    
    
        
            JSP Template Inheritance
        
    
    

    Head

    header

    Contents

    Contents will be placed under this h2

    view.jsp : contents

    <%@page contentType="text/html; charset=UTF-8" %>
    <%@ taglib uri="http://kwonnam.pe.kr/jsp/template-inheritance" prefix="layout"%>
    
        
            

    This is an example about layout management with JSP Template Inheritance

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin porta, augue ut ornare sagittis, diam libero facilisis augue, quis accumsan enim velit a mauris.

提交回复
热议问题