home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (FreeMarkerTemplateUtils.java)

This example Spring Framework source code file (FreeMarkerTemplateUtils.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

freemarkertemplateutils, io, ioexception, ioexception, object, object, string, stringwriter, stringwriter, templateexception, templateexception

The Spring Framework FreeMarkerTemplateUtils.java source code

 * Copyright 2002-2005 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

package org.springframework.ui.freemarker;

import java.io.IOException;
import java.io.StringWriter;

import freemarker.template.Template;
import freemarker.template.TemplateException;

 * Utility class for working with FreeMarker.
 * Provides convenience methods to process a FreeMarker template with a model.
 * @author Juergen Hoeller
 * @since 14.03.2004
public abstract class FreeMarkerTemplateUtils {

	 * Process the specified FreeMarker template with the given model and write
	 * the result to the given Writer.
	 * <p>When using this method to prepare a text for a mail to be sent with Spring's
	 * mail support, consider wrapping IO/TemplateException in MailPreparationException.
	 * @param model the model object, typically a Map that contains model names
	 * as keys and model objects as values
	 * @return the result as String
	 * @throws IOException if the template wasn't found or couldn't be read
	 * @throws freemarker.template.TemplateException if rendering failed
	 * @see org.springframework.mail.MailPreparationException
	public static String processTemplateIntoString(Template template, Object model)
			throws IOException, TemplateException {
		StringWriter result = new StringWriter();
		template.process(model, result);
		return result.toString();


Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework FreeMarkerTemplateUtils.java source code file:

my book on functional programming


new blog posts


Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.