GVKun编程网logo

StringTemplate remove <>作为分隔符(string以.分割)

19

关于StringTemplateremove<>作为分隔符和string以.分割的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Anerrorhappenedduringtemplatep

关于StringTemplate remove <>作为分隔符string以.分割的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于An error happened during template parsing (template: "class path resource [templates/index.h...、An error happened during template parsing (template: "class path resource [templates/user.html]、c# – StringTemplate中的回调或简单算术、c# – StringTemplate中的嵌套循环等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

StringTemplate remove <>作为分隔符(string以.分割)

StringTemplate remove <>作为分隔符(string以.分割)

我正在尝试在Java Web应用程序中使用StringTemplate生成HTML电子邮件。当尝试输入换行符时,我使用“ \<br\>这似乎不起作用”。
\<b\>效果不佳。有没有办法关闭<和>作为定界符,以便我可以测试这是否是问题所在?整个StringTemplate文档都说使用$ …
$作为分隔符,但没有说明如何不使用<…>

答案1

小编典典

创建组时,可以使用以下命令设置分隔符

STGroup group = new STGroupDir("emails", ''$'',''$'');

其中“ $”和“ $”是您的分隔符。

An error happened during template parsing (template:

An error happened during template parsing (template: "class path resource [templates/index.h...

转自 https://blog.csdn.net/qq_41426326/article/details/88837112

在开发 springboot 的时候,进行 modelAndView 视图层映射的时候,一直出现 

An error happened during template parsing (template: "class path resource [templates/index.html]")

模板解析过程中发生错误 (模板:“类路径资源 [templates/index.html]”)

在向 index.html 映射的时候出现错误,小编在和其他程序员一样打开了百度开始搜索,有各种说法

1. 配置文件问题.(我重新看了一遍确定没有问题,但是还是错误)

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.encoding=utf-8
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/static/
2. 说是 @Controller 和 @RestController 功能不一样,将 @Controller 修改为 @RestController 在加上 @ResponseBody (依然无效)、

3. 说在映射的时候实体类没有 get 方法,为变量加上 get 就可以了(结果我本来就有 get 方法的)

4. 还有说在 pom.xml 文件下的 build 配置 (都不是这个错误的解决方案)

<resources>
<resource>
<directory>sre/main/resources</directory>
</resource>
</resources>
最后小编早上智商最高峰的时候发现了这个小小小问题

 

在这附上小编 index.html 的文件开头,就是因为加了

https: xmlns:https="http://www.w3.org/1999/xhtml"

xmlns:th="http://www.thymeleaf.org"
导致调用的时候原本要调用第二句话的代码调用了第一句代码中的方法发生错误,把第一句代码删除就可以了

小编总结了一下,一般系统出现以下错误

An error happened during template parsing (template: "class path resource [templates/index.html]")

大家可以去看看视图层,并不是 java 代码出现错误.

An error happened during template parsing (template: "class path resource [templates/user.html]

An error happened during template parsing (template: "class path resource [templates/user.html]

问题:

An error happened during template parsing (template: "class path resource [templates/user.html]")

 

 解决方法:

1.配置文件问题。根据问题描述,问题可能为想要去的地址路径错误。解决方法:修改路径。

 

 

 

 2.@RestController

@RestController相当于@Response + @Controller,作用是将return的字符串响应在界面上。

而@Controller作用是将return中的字符串拼接配置文件中的前后缀,形成一个html地址,最后在网页上指向这个地址界面。

 两者作用不同。

 

3.为变量加上get

实体类中可能没有getter and setter方法,加上。

或者可能是LomBok出问题了,重启或者刷新maven包可能可以解决。

 

4.xmlns冲突。可能同时设置了 “https: xmlns:https="http://www.w3.org/1999/xhtml" ”和 “xmlns:th="http://www.thymeleaf.org" ”。删去“https: xmlns:https="http://www.w3.org/1999/xhtml" ”即可。

 

5.(我的问题)进行select搜索时,数据库中没有id=“111”这个数据!所以导致页面跳转指向不明,导致错误TAT

 

高了,血压高了!!!

 

写代码须细心啊TAT

   

c# – StringTemplate中的回调或简单算术

c# – StringTemplate中的回调或简单算术

我想在StringTemplate中使用类似的东西 – 调用在执行渲染的应用程序中定义的函数,这可能吗?

<div> $renderArticle(article,width,padding)$</div>

我可以使用一个自定义类型/类只是为了这个领域,但这似乎有点被攻击,而不是问题的真正解决方案,并且它不会允许我传递参数据我所知.

我希望这是因为我想允许用户自定义模板,例如:我知道我可以为文章提供多少宽度,但我希望用户能够指定填充,以便我可以在该模板中生成最佳图像缩略图.

或者,如果可以使用简单的算术,那将是问题的另一种解决方案,这可能是这样的:

... width="$width-50$...

我一直在寻找这个,没有找到任何信息……

我宁愿使用StringTemplate,因为应用程序已经使用它,但如果它更适合我可以切换到别的东西,也许我应该看看NVeLocity?

解决方法

正如I82Much在他的评论中所说,StringTemplate不支持计算.

一种解决方案是使用新属性来丰富您的模型,该属性的值预先计算为“width-50”.

如果您正在寻找替代方案,并且您正在使用.net 4.0,则可以托管剃刀视图引擎并将其用作模板解决方案.

c# – StringTemplate中的嵌套循环

c# – StringTemplate中的嵌套循环

我有兴趣使用StringTemplate模板引擎编写类似于嵌套循环的东西.
在C#中有一个HashTable,其中每个Key包含Document对象列表,每个Document都有一个标题和源.我想列出电子邮件的开头,每个来源的文档标题摘要.
<h1>Summary</h1>
<h2>Source A</h2>
<ul>
  <li>title 1</li>
  <li>title 2</li> 
</ul>
<h2>Source B</h2>
<ul>
  <li>title 3</li>
  <li>title 4</li> 
</ul>

使用StringTemplate实现此目的的最佳方法是什么?

解决方法

假设您已将这些转换为适当的数据结构 – 具有getName和getDocuments方法的Source类,以及具有getTitle方法的Document类,它将如下所示:
$
sources:
 {
    source|
    <h2>Source $source.name$</h2>
    $
    source.documents:
     {
      document|
      <li>title $document.title$</li>
     }
    $
 }
$

关于StringTemplate remove <>作为分隔符string以.分割的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于An error happened during template parsing (template: "class path resource [templates/index.h...、An error happened during template parsing (template: "class path resource [templates/user.html]、c# – StringTemplate中的回调或简单算术、c# – StringTemplate中的嵌套循环的相关信息,请在本站寻找。

本文标签: