论坛首页 Java企业应用论坛

Webwork提供的FreemarkerServlet所配置的TemplatePath有什么...

浏览 4801 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2005-09-01  
<servlet>
		<servlet-name>freemarker</servlet-name>
		<servlet-class>
			com.opensymphony.webwork.views.freemarker.FreemarkerServlet
		</servlet-class>
		<init-param>
			<param-name>TemplatePath</param-name>
			<param-value>/</param-value>
		</init-param>
</servlet>




读了一下源码,没有弄明白,好像不设置这个值也没有什么影响,这个东东到底有什么好处呢?????
   发表时间:2005-09-01  
读一下FreemarkerManager,是有用的

我没设置过
0 请登录后投票
   发表时间:2005-09-05  
这个东东怎么用啊,我也没看明白
0 请登录后投票
   发表时间:2005-09-05  
好像可以这样用:
&lt;param-name&gt;TemplatePath&lt;/param-name&gt;
&lt;param-value&gt;/WEB-INF/&lt;/param-value&gt;
0 请登录后投票
   发表时间:2005-09-05  
andiyang 写道
这个东东怎么用啊,我也没看明白



Api JavaDoc是这样说的:
Supported init-params are:
[list]
TemplatePath specifies the location of the templates. By default, this is interpreted as web application directory relative URI.
Alternatively, you can prepend it with file:// to indicate a literal path in the file system (i.e. file:///var/www/project/templates/). Note that three slashes were used to specify an absolute path.
Also, you can prepend it with class://path/to/template/package to indicate that you want to load templates from the specified package accessible through the classloader of the servlet.
Default value is class:// (that is, the root of the class hierarchy). Note that this default is different than the default in FreeMarker 1.x, when it defaulted /, that is to loading from the webapp root directory.
[/list:u][list]
NoCache if set to true, generates headers in the response that advise the HTTP client not to cache the returned page. The default is false.
[/list:u][list]
ContentType if specified, response uses the specified Content-type HTTP header. The value may include the charset (e.g. "text/html; charset=ISO-8859-1"). If not specified, "text/html" is used. If the charset is not specified in this init-param, then the charset (encoding) of the actual template file will be used (in the response HTTP header and for encoding the output stream). Note that this setting can be overridden on a per-template basis by specifying a custom attribute named content_type in the attributes parameter of the &lt;#ftl&gt; directive.
[/list:u][list]
The following init-params are supported only for backward compatibility, and their usage is discouraged: TemplateUpdateInterval, DefaultEncoding, ObjectWrapper, TemplateExceptionHandler. Use setting init-params such as object_wrapper instead.
[/list:u][list]
Any other init-param will be interpreted as Configuration level setting. See Configuration.setSetting(java.lang.String, java.lang.String)
[/list:u]
0 请登录后投票
   发表时间:2005-09-06  
在ww中,没必要这样用freemarker

不需要在web.xml中配freemarker的servlet,只需要在xwork.xml中这样写
            &lt;result name="input" type="freemarker"&gt;
                &lt;param name="location"&gt;/infoAdd.ftl&lt;/param&gt;
            &lt;/result&gt;


另外,你也可以用“变量”,比如
            &lt;result name="success" type="freemarker"&gt;
                &lt;param name="location"&gt;/template/${id}.ftl&lt;/param&gt;
            &lt;/result&gt;
1 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics