Package freemarker.ext.servlet
Class IncludePage
- java.lang.Object
-
- freemarker.ext.servlet.IncludePage
-
- All Implemented Interfaces:
TemplateDirectiveModel,TemplateModel
public class IncludePage extends java.lang.Object implements TemplateDirectiveModel
A model that when invoked with a 'path' parameter will perform a servlet include. It also support an optional hash named 'params' which specifies request parameters for the include - its keys are strings, its values should be either strings or sequences of strings (for multiple valued parameters). A third optional parameter 'inherit_params' should be a boolean when specified, and it defaults to true when not specified. A value of true means that the include inherits the request parameters from the current request. In this case values in 'params' will get prepended to the existing values of parameters.
-
-
Field Summary
-
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
-
Constructor Summary
Constructors Constructor Description IncludePage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute(Environment env, java.util.Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)Executes this user-defined directive; called by FreeMarker when the user-defined directive is called in the template.
-
-
-
Method Detail
-
execute
public void execute(Environment env, java.util.Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, java.io.IOException
Description copied from interface:TemplateDirectiveModelExecutes this user-defined directive; called by FreeMarker when the user-defined directive is called in the template.This method should not throw
RuntimeException, norIOExceptionthat wasn't caused by writing to the output. Such exceptions should be catched inside the method and wrapped inside aTemplateException. (Note that settingConfiguration.setWrapUncheckedExceptions(boolean)totruecan mitigate the negative effects of implementations that throwRuntimeException-s.)- Specified by:
executein interfaceTemplateDirectiveModel- Parameters:
env- the current processing environment. Note that you can access the outputWriterbyEnvironment.getOut().params- the parameters (if any) passed to the directive as a map of key/value pairs where the keys areString-s and the values areTemplateModelinstances. This is nevernull. If you need to convert the template models to POJOs, you can use the utility methods in theDeepUnwrapclass.loopVars- an array that corresponds to the "loop variables", in the order as they appear in the directive call. ("Loop variables" are out-parameters that are available to the nested body of the directive; see in the Manual.) You set the loop variables by writing this array. The length of the array gives the number of loop-variables that the caller has specified. Nevernull, but can be a zero-length array.body- an object that can be used to render the nested content (body) of the directive call. If the directive call has no nested content (i.e., it's like <@myDirective /> or <@myDirective></@myDirective>), then this will benull.- Throws:
TemplateException- If any problem occurs that's not anIOExceptionduring writing the template output.java.io.IOException- When writing the template output fails. OtherIOException-s should be catched in this method and wrapped intoTemplateException.
-
-