JSP vs Velocity what is better?

前端 未结 8 2162
滥情空心
滥情空心 2020-12-25 11:49

What is better between JSP and velocity in - Performance - Ease of use - Ease of creating reusable components - Availability of open source 3rd parties - IDE support

8条回答
  •  佛祖请我去吃肉
    2020-12-25 12:39

    The below is about Freemarker, but the comparisons are probably still relevant.

    At this point in these two technologies' development, it seems like the primary reasons to choose one over the other are:

    1. There is something specific that you need that is in one and not the other
    2. You want to prevent view developers from putting Java scriptlets into JSP pages
    3. Your developers are more comfortable in one than the other

    Reasons that don't seem to have as much of an impact:

    1. Speed. There are so many layers in a typical Java EE app that have a much greater impact than the couple of milliseconds more or less that a view renderer might take. In fact, this is probably the last layer I would tackle if my app was performing subpar.
    2. IDE support. JBoss Tools provides a Freemarker editor, and JSP tools are well known.
    3. Syntax. JSP 2 and Freemarker have virtually identical syntax for many basic operations, because of EL and JSTL.

    Freemarker Example:

    <#list foos as foo>
      
         ${foo.field1}
         ${foo.field2}
         
            <#list foo.childObjects as child>
               <#if child.name == 'bar'>
                  ${child.value}
               
            
         
      
    
    

    JSP-EL-JSTL Example:

    
      
         ${foo.field1}
         ${foo.field2}
         
            
               
                  ${child.value}
               
            
         
      
    
    

提交回复
热议问题