Freemarker of Web page static

Source: Internet
Author: User

Why use Web-static technology?

Provides concurrent hosting for some sites that have a huge amount of instantaneous access to reduce database pressure. It has a common denominator with cache technology to alleviate the database's access pressure but uses different scenarios. Caching is better suited to small-scale data, and Web pages are statically adapted to large-scale and relatively infrequently variable data. At the same time it facilitates the use of SEO: For example, in the e-Commerce Product Details page or in, the media article reports.
Getting Started with: 1. Add Freemarker related documentation plugin to eclipse
2. Import related dependencies in the project
3. Creating a template file
Template Four elements: text, annotations, interpolation, FTL instructions

Create:

    1. Create config class configuration

         configuration=new configuration (Configuration.getversion ());//getversion get the latest version to avoid hints out of date

         //2. Set the directory where the template resides

         configuration.setdirectoryfortemplateloading ("d:***");

         3. Setting the character set

         configuration.setdefaultencoding ("Utf-8");

         4. Load templates Template

         = Configuration.gettemplate ("TEST.FTL");

         5. Create a data Model

         Map map=new HashMap ();

         Map.put ("name", "Civet cat");

         Map.put ("message", "shovel a great lump of excrement");

         6. Create writer Object

         writer out =new FileWriter ("d:*****");

         7. Output

         template.process (map, out);

         8. Close Writer Object

         out.close ();
detailed label and use command reference: http://blog.csdn.net/fhx007/article/details/7902040/

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.