简体   繁体   English

Freemarker寻找默认模板

[英]Freemarker Looking For Default Templates

I set up a template directory through struts.ui.templateDir in my struts.xml. 我通过struts.xml中的struts.ui.templateDir设置了模板目录。 Now, when I access my page, a java.io.FileNotFoundException comes up looking for a bunch of files that I can only guess Freemarker is looking for by default. 现在,当我访问页面时,出现java.io.FileNotFoundException来查找一堆文件,这些文件我只能猜测Freemarker默认正在查找。

Here is one such file: 这是一个这样的文件:

java.io.FileNotFoundException: Template /WEB-INF/templates/simple/form-close.ftl not found.

I do not want this file or any other file other than the templates I create to be looked for. 我不希望查找此文件或除我创建的模板以外的任何其他文件。 Is there some way to prevent Freemarker from doing this? 有什么方法可以防止Freemarker这样做吗? Also, where is there documentation for this library? 另外,该库在哪里有文档? I cannot seem to find anything other than blog sites... 除了博客网站,我似乎找不到其他任何东西。

Basicly any struts-tag uses one or more *.ftl to render a specific tag to the page (they are required). 基本上,任何struts-tag都使用一个或多个* .ftl将特定标签呈现到页面上(它们是必需的)。

You cant 'just remove' some of the templates. 您不能“仅删除”某些模板。 If you want to write your own templates, copy all ftls from the struts jar (templates.simple) to your template dir. 如果要编写自己的模板,请将所有ftls从struts jar(templates.simple)复制到模板目录。 Then replace the ftls you want to change. 然后替换要更改的ftls。

Overriding struts.xml is not nessecary most of the time, you can also set your template path and standard theme via struts.properties. 在大多数情况下,覆盖struts.xml并不是必需的,您还可以通过struts.properties设置模板路径和标准主题。

### Standard UI theme
struts.ui.theme=xhtml
struts.ui.templateDir=template

Update to your comment: I thought, you want to provide your own templates. 更新您的评论:我想,您想提供自己的模板。 But you can also specify the 'theme' property for the struts tags to change a single ftl for any tag. 但是,您也可以为struts标签指定'theme'属性,以更改任何标签的单个ftl。

<s:select name="myName" theme="myTheme" />

Then create your select.ftl and add it under src/main/resources/template/myTheme. 然后创建您的select.ftl并将其添加到src / main / resources / template / myTheme下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM