|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport org.springframework.web.servlet.view.AbstractView org.springframework.web.servlet.view.AbstractUrlBasedView org.springframework.web.servlet.view.freemarker.FreeMarkerView
View using the FreeMarker template engine.
Exposes the following JavaBean properties:
Depends on a single FreeMarkerConfig object such as FreeMarkerConfigurer being accessible in the current web application context, with any bean name. Alternatively, you can set the Freemarker Configuration object as bean property.
Note: Spring's FreeMarker support requires FreeMarker 2.3 or higher.
AbstractUrlBasedView.setUrl(java.lang.String)
,
setEncoding(java.lang.String)
,
setConfiguration(freemarker.template.Configuration)
,
FreeMarkerConfig
,
FreeMarkerConfigurer
Field Summary |
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
logger |
Constructor Summary | |
FreeMarkerView()
|
Method Summary | |
protected freemarker.template.Configuration |
getConfiguration()
Return the FreeMarker configuration used by this view. |
protected java.lang.String |
getEncoding()
Return the encoding for the FreeMarker template. |
protected freemarker.template.Template |
getTemplate(java.util.Locale locale)
Retrieve the FreeMarker template for the given locale. |
protected void |
initApplicationContext()
Invoked on startup. |
protected void |
processTemplate(freemarker.template.Template template,
java.util.Map model,
javax.servlet.http.HttpServletResponse response)
Process the FreeMarker template to the servlet response. |
protected void |
renderMergedOutputModel(java.util.Map model,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Process the model map by merging it with the FreeMarker template. |
void |
setConfiguration(freemarker.template.Configuration configration)
Set the FreeMarker Configuration to be used by this view. |
void |
setEncoding(java.lang.String encoding)
Set the encoding of the FreeMarker template file. |
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView |
getUrl, setUrl |
Methods inherited from class org.springframework.web.servlet.view.AbstractView |
addStaticAttribute, getBeanName, getContentType, getStaticAttributes, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute |
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
getServletContext, getTempDir, getWebApplicationContext, requiredContextClass |
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
getApplicationContext, getMessageSourceAccessor, setApplicationContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FreeMarkerView()
Method Detail |
public void setEncoding(java.lang.String encoding)
Specify the encoding in the FreeMarker Configuration rather than per template if all your templates share a common encoding.
protected java.lang.String getEncoding()
public void setConfiguration(freemarker.template.Configuration configration)
FreeMarkerConfig
protected freemarker.template.Configuration getConfiguration()
protected void initApplicationContext() throws BeansException
Checks that the template for the default Locale can be found: FreeMarker will check non-Locale-specific templates if a locale-specific one is not found.
initApplicationContext
in class AbstractUrlBasedView
BeansException
TemplateCache.getTemplate(java.lang.String, java.util.Locale, java.lang.String, boolean)
protected void renderMergedOutputModel(java.util.Map model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, freemarker.template.TemplateException
renderMergedOutputModel
in class AbstractView
model
- combined output Map, with dynamic values taking precedence
over static attributesrequest
- current HTTP requestresponse
- current HTTP response
java.io.IOException
freemarker.template.TemplateException
protected freemarker.template.Template getTemplate(java.util.Locale locale) throws java.io.IOException
locale
- the current locale
java.io.IOException
- if the template file could not be retrievedprotected void processTemplate(freemarker.template.Template template, java.util.Map model, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, freemarker.template.TemplateException
template
- the template to processmodel
- the model for the templateresponse
- servlet response (use this to get the OutputStream or Writer)
java.io.IOException
freemarker.template.TemplateException
Template.process(Object, java.io.Writer)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |