JSP tricks to make templating easier?

前端 未结 7 765
猫巷女王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条回答
  •  Happy的楠姐
    2020-11-22 09:23

    Use tiles. It saved my life.

    But if you can't, there's the include tag, making it similar to php.

    The body tag might not actually do what you need it to, unless you have super simple content. The body tag is used to define the body of a specified element. Take a look at this example:

        
       ${content.lang}   
       ${content.body} 
    
    

    You specify the element name, any attributes that element might have ("lang" in this case), and then the text that goes in it--the body. So if

    • content.headerName = h1,
    • content.lang = fr, and
    • content.body = Heading in French

    Then the output would be

    Heading in French

提交回复
热议问题