简体   繁体   English

如何将其转换为速度模板?

[英]How to convert this for velocity template?

I have html content. 我有html内容。 I want to convert it to velocity template. 我想将其转换为速度模板。 Please provide the steps to be taken to convert it to template. 请提供将其转换为模板的步骤。

I need to insert the html in database also. 我还需要在数据库中插入html。

Following is the html : 以下是html:

<div class="divNumberFilter">
    <div class="divLabel" style="width: 70px;">Number:</div>
    <div class="divInputField">
        <input id="$tags.searchStandard" type="text" style="width: 100px;">
        <script src='<s:url value=""></s:url>' type="text/javascript"></script>
        <script type="text/javascript" charset="utf-8">
            addOnload(grouping());
            addOnload(initilizeStandardAutoComplete());
        </script>
    </div>
    <div class="clear"></div>
</div>

<!-- Standard Description filter -->
<div class="divDescriptionFilter">
    <div class="divLabel" style="width: 70px;">Description:</div>
    <div class="divInputField">
        <input id="$tags.standardFilter" type="text" style="width: 318px;">
        <script src='<s:url value=""></s:url>' type="text/javascript"></script>
        <script type="text/javascript" charset="utf-8">
            addOnload(grouping());
            addOnload(initilizeStandardDescAutoComplete());
        </script>
    </div>
    <div class="clear"></div>
</div>
<div id="standard_list" class="selection_property_div" style="padding-bottom: 5px;">
</div>

Please help.. 请帮忙..

Okay first of all, to convert this into a Velocity template, you must have an idea what you EXACTLY want to do. 好的,首先,要将其转换为Velocity模板,您必须了解您确切想做什么。 That's step 1. 那是第一步。

Then start writing the code in a velocity template file. 然后开始在速度模板文件中编写代码。 Figure out what part would be dynamic, ie, would be rendered by the Velocity Template Engine., which I guess you already know. 找出哪个部分是动态的,即由Velocity Template Engine。渲染,我想您已经知道了。

<input id="$tags.standardFilter" type="text" style="width: 318px;">

Inserting it into database. 将其插入数据库。

You would need a table structure like this. 您将需要一个这样的表结构。

create table if not exists Templates (
    template_file_name varchar(50), --The column to store the name of templates.
    html mediumblob, --The column which actually has the velocity templates.
    lastmod timestamp --The column which contains the last modification information.
);

Then use the DataSourceResourceLoader and configure it (please read Velocity Docs for reference). 然后使用DataSourceResourceLoader进行配置(请阅读Velocity Docs以供参考)。

Make a VelocityEngine out of the configurations of the DataSourceResourceLoader . DataSourceResourceLoader的配置制作一个VelocityEngine

have FUN. 玩得开心。

--Cheers, Jay. -干杯,周杰伦。

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

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