Advantages and disadvantages of FreeMarker you don't know

Source: Internet
Author: User

First, let's give a brief introduction to FreeMarker. FreeMarker is a Java template engine that generates text output based on the template. FreeMarker has nothing to do with the Web Container, that is, when the Web is running, it does not know Servlet or HTTP. It can not only be used as the Implementation Technology of the presentation layer, but also be used to generate XML, JSP, or Java files. After a brief understanding of FreeMarker, let's talk about the advantages and disadvantages of FreeMarker.
(1)FreeMarkerBenefits
1.FreeMarkerAdvantage 1To completely separate the presentation layer and business logic.
In the past, the waves found a large number of business logic code in the page during the JSP development process, making the page content messy and becoming very difficult in the subsequent modification and maintenance process.
FreeMarker does not support Java Script code at all.
FreeMarker's principle is: Template + Data Model = output. The template is only responsible for the presentation of data on the page and does not involve any logic code. All logics are processed by the data model. The final output is created after the template and data model are merged.

2.FreeMarkerAdvantage 2To improve development efficiency.
Based on the previous development experience of the waves, JSP pages are used to display data, that is, the so-called performance layer. As we all know, JSP needs to be converted into a Servlet class during the first execution. during the development stage, the function is adjusted in a timely manner and JSP needs to be modified frequently. Compilation and conversion are required for each modification, let's imagine how much time we waste in program compilation in a day. Compared with JSP, FreeMarker template technology does not have compilation and conversion problems, so the above problems do not exist. In addition, during the development process, you do not have to wait for the interface design and development personnel to complete the page prototype before you start to develop the program.

3.FreeMarkerAdvantage 3To clarify the division of labor in the development process. In the past, when JSP was used to present data, as programmers, we were not familiar with the interface design technology. On the contrary, interface developers were not familiar with the programming language. For both, the alternative work itself is difficult. Sometimes, you may accidentally delete a page element or remove a program symbol to make the page sample or program error. In this way, both parties need to communicate and cooperate with each other to solve the problem. Sometimes, because of project time, task volume, and other factors, this work may be completed by one person, which may increase the workload of a developer.
After FreeMarker is used, as an interface developer, only focus on creating HTML files, images, and other visual aspects of web pages, so you do not need to care about data. program developers focus on system implementation, prepares the data to be displayed for the page.
(2)FreeMarkerDisadvantages
1.FreeMarker disadvantage 1By using FreeMarker template technology, expired data may be displayed after the template is modified. For example, after a static HTML page is generated, if the template is changed but the HTML page generated by the template is not updated in time, the user will see expired data.
2.FreeMarkerDisadvantage 2, FreeMarker template technology in the application process, the variables in FreeMarker must be assigned a value. If not assigned a value, an exception is thrown. To avoid errors, you need to use the if/elseif/else command to determine the segment. if you judge every variable, it increases programming complexity.
3.Fault 3 of FreeMarkerThe map key of FreeMarker must be string, and other data types cannot be operated.
4.FreeMarker disadvantage 4FreeMarker does not support cluster applications. For convenience of compilation, all serialized items are put into the Session, such as Session and request, which is indeed convenient in the development process. However, if the application is put into the cluster, an error occurs.

Now, I believe that you have some knowledge about the advantages and disadvantages of FreeMarker. If you have any other comments about FreeMarker's advantages and disadvantages, you can leave a message, the waves are very willing to discuss with you.

This article is from the "oecp community" blog, please be sure to keep this source http://oecpby.blog.51cto.com/2203338/411901

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.