我正在尝试处理模板(见下文),我在eclipse控制台中收到各种消息。
我在网上搜索但是找不到我要找的东西。我记得在这里看到了关于这个主题的一些内容,但我当时没有给它添加书签,也找不到了! :/
你能帮帮忙吗?感谢PS。我正在尝试使用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&method=popup&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 '>'
答案 0 :(得分:7)
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 />
>>
如果您不想更改模板以包含原型,可以使用STRawGroupDir
代替STGroupDir
,added in ST 4.0.5。
答案 1 :(得分:0)
请参阅此帖子,我认为它可以回答您的问题:How to exclude specific folders or files from validation in Eclipse?
您只会排除* .st文件的验证。
答案 2 :(得分:0)
这是告诉如何确保html实体在字符串模板中转义的链接, What is the best way to ensure HTML entities are escaped in StringTemplate