4

我正在尝试处理模板(见下文),并且在 Eclipse 控制台中收到各种消息。

我已经搜索了网络,但无法真正找到我正在寻找的东西。我记得在这里看到过有关此主题的内容,但当时我没有将其添加为书签,并且无法再次找到它!:/

你能帮忙吗?谢谢

附言。我正在尝试使用 StringTemplate 构建电子邮件。并使用 HTML 标签为我们的客户“更容易阅读”。

用于加载我的模板的 java 代码

STGroup stGroup = new STGroupDir("/resources/emailTemplates", '$', '$');
ST emailBody = stGroup.getInstanceOf("Fab");

我的模板

<h3>Thank you for submitting your details.</h3>
Student ID: $studentId$<br />
Family Name: $familyName$<br />
Given Name: $givenName$<br />
Gender: $gender$<br />Course: $course$<br />
<h3>This is the final confirmation for MyApps Arrival Briefing (FAB).</h3>
$first$
</p><p>
$previous$
<p></p>
<p>If you have to cancel a booking please notify us by email: <a href="mailto:issu@">issu@myapps.com</a>. <br>For booking an additional event please revisit the <a href="http://www.myapps.com/international-students/services/">ISSU website</a> and submit another booking. <br>If you have difficulties finding the venues please ask for help at ISSU. <br><br>The ISSU is located in the basement (B 10)</a> of the Union building (building 25 on the <a href="http://www.myapps.com/MyApps/app_templates/behaviours/popup.cfm?file_uuid=90DE8CF7-C571-D75A-CB7A-37DA9D470AB4&amp;method=popup&amp;alt=%27MyApps%20Map%20showing%20ISSU%20location_thumb.png">campus map</a>).</p> 

这是我收到的关于模板的错误消息

Fab.st 1:1: invalid character '<'
Fab.st 1:3: invalid character '>'
Fab.st 1:1: no viable alternative at input 'h3'
Fab.st 1:43: invalid character '<'
Fab.st 1:44: invalid character '/'
Fab.st 1:46: invalid character '>'
Fab.st 2:12: invalid character '$'
Fab.st 2:22: invalid character '$'
Fab.st 2:24: invalid character '<'
Fab.st 2:28: invalid character '/'
Fab.st 2:28: invalid character '>'
Fab.st 3:13: invalid character '$'
Fab.st 3:24: invalid character '$'
Fab.st 3:26: invalid character '<'
Fab.st 3:30: invalid character '/'
Fab.st 3:30: invalid character '>'
Fab.st 4:12: invalid character '$'
Fab.st 4:22: invalid character '$'
Fab.st 4:24: invalid character '<'
Fab.st 4:28: invalid character '/'
Fab.st 4:28: invalid character '>'
Fab.st 5:8: invalid character '$'
Fab.st 5:15: invalid character '$'
Fab.st 5:17: invalid character '<'
Fab.st 5:21: invalid character '/'
Fab.st 5:21: invalid character '>'
Fab.st 5:30: invalid character '$'
Fab.st 5:37: invalid character '$'
Fab.st 5:39: invalid character '<'
Fab.st 5:43: invalid character '/'
Fab.st 5:43: invalid character '>'
Fab.st 6:1: invalid character '<'
Fab.st 6:3: invalid character '>'
Fab.st 6:72: invalid character '<'
Fab.st 6:73: invalid character '/'
Fab.st 6:75: invalid character '>'
Fab.st 7:0: invalid character '$'
Fab.st 7:6: invalid character '$'
Fab.st 8:1: invalid character '<'
Fab.st 8:2: invalid character '/'
Fab.st 8:3: invalid character '>'
Fab.st 8:5: invalid character '<'
Fab.st 8:6: invalid character '>'
Fab.st 9:0: invalid character '$'
Fab.st 9:9: invalid character '$'
Fab.st 10:1: invalid character '<'
Fab.st 10:2: invalid character '>'
Fab.st 10:4: invalid character '<'
Fab.st 10:5: invalid character '/'
Fab.st 10:6: invalid character '>'
Fab.st 11:1: invalid character '<'
Fab.st 11:2: invalid character '>'
Fab.st 11:63: invalid character '<'
Fab.st 11:99: invalid character '>'
Fab.st 11:121: invalid character '<'
Fab.st 11:122: invalid character '/'
Fab.st 11:123: invalid character '>'
Fab.st 11:127: invalid character '<'
Fab.st 11:129: invalid character '>'
Fab.st 11:182: invalid character '<'
Fab.st 11:250: invalid character '>'
Fab.st 11:264: invalid character '<'
Fab.st 11:265: invalid character '/'
Fab.st 11:266: invalid character '>'
Fab.st 11:297: invalid character '<'
Fab.st 11:299: invalid character '>'
Fab.st 11:374: invalid character '<'
Fab.st 11:376: invalid character '>'
Fab.st 11:378: invalid character '<'
Fab.st 11:380: invalid character '>'
Fab.st 11:420: invalid character '1'
Fab.st 11:421: invalid character '0'
Fab.st 11:424: invalid character '<'
Fab.st 11:425: invalid character '/'
Fab.st 11:426: invalid character '>'
Fab.st 11:460: invalid character '2'
Fab.st 11:461: invalid character '5'
Fab.st 11:471: invalid character '<'
Fab.st 11:678: invalid character '>'
Fab.st 11:690: invalid character '<'
Fab.st 11:691: invalid character '/'
Fab.st 11:692: invalid character '>'
Fab.st 11:696: invalid character '<'
Fab.st 11:697: invalid character '/'
Fab.st 11:698: invalid character '>'
4

3 回答 3

8

StringTemplate 4 为松散模板(*.st文件)使用了一种新格式,因此它们在内部字节码表示中使用的新参数传递方案可以更好地执行。以前看起来像这样的模板文件:

example.st(版本 3)

Student ID: $studentId$<br />
Family Name: $familyName$<br />
Given Name: $givenName$<br />

现在看起来像这样:

example.st(版本 4)

example(studentId, familyName, givenName) ::= <<
Student ID: $studentId$<br />
Family Name: $familyName$<br />
Given Name: $givenName$<br />
>>

如果您不想更改模板以包含原型,您可以使用在 ST 4.0.5中添加的STRawGroupDir代替。STGroupDir

于 2013-01-30T03:27:59.630 回答
1

这是告诉如何确保 html 实体在字符串模板中转义的链接, 什么是确保 HTML 实体在 StringTemplate 中转义的最佳方法

于 2013-01-30T02:23:53.930 回答
0

看到这篇文章,我认为它回答了你的问题:如何在 Eclipse 中从验证中排除特定文件夹或文件?

您只需将 *.st 文件排除在验证之外。

于 2013-01-30T02:23:17.577 回答