First you have to create a freemarker.template.Configuration instance and adjust its settings. A Configuration instance is a central place to store the appliction level setting of FreeMarker. Also, it deals with the creation and caching of pre-parsed templates.
棣栧厛浣犲繀欏誨緩绔嬩竴涓猣reemarker.template.Configuration綾葷殑瀹炰緥騫惰皟鏁村畠鐨勮緗? 涓涓狢onfiguration綾誨疄渚嬫槸淇濆瓨Freemarker搴旂敤紼嬪簭璁劇疆鐨勪腑蹇冮瑕? 鍚屾牱, 瀹冨喅瀹氱潃棰勭紪璇戞ā鐗堢殑寤虹珛鍜岀紦鍐?
Probably you will do it only once at the beginning of the application(possibly servlet) life-cycle:
涔熻浣犲彧闇瑕佸湪紼嬪簭寮濮嬫椂,浠呬粎鍙渶璋冪敤涓嬈′笅闈㈢殑浠g爜,騫朵笖鍦ㄧ▼搴忕殑鏁翠釜鐢熷懡鍛ㄦ湡閮藉彲鐢?
From now you should use this single configuration instance. Note however that if a system has multiple independent components that use FreeMarker, then of course they will use their own private Configuration instance.
鐜板湪寮濮?浣犲氨鍙互浣跨敤榪欎釜Configuration瀹炰緥浜? 濡傛灉涓涓郴緇熸湁澶氫釜妯″潡浣跨敤Freemarker鐨勮瘽, 姣棤鎰忓鐨? 瀹冧滑鏈鍚庝嬌鐢ㄥ畠浠悇鑷鏈夌殑Configuration瀹炰緥.