在Thymeleaf中使用带有查询字符串的静态href

时间:2015-06-20 00:17:05

标签: spring apache thymeleaf

我有一个应用程序的html原型,这个原型在Apache服务器上,我使用Apache Server Side Includes来包含模板布局的不同页面。

现在我正在添加标签Thymeleaf,该原型用于Spring的应用程序。 问题是所使用的许多URL都需要使用查询字符串来加载Apache内容,并使用Thymeleaf生成错误。

例如,静态原型中的链接如下所示:

<a href="index.html?seccion=asignaturas&area=materiales-editar"><i class="fa fa-plus-circle"></i> Registrar material</a>

添加Thymeleaf应如下所示:

<a href="index.html?seccion=asignaturas&area=materiales-editar" th:href="@{/asignaturas/{idAsignatura}/seccion/{idSeccion}/materiales/registro.html(idAsignatura=${asignatura.id},idSeccion=${asignatura.idSeccion},idfuncion=${param.idfuncion},idmodulo=${param.idmodulo})}"><i class="fa fa-plus-circle"></i> Registrar material</a>

但应用程序崩溃,错误检查静态查询字符串网址(?seccion = asignaturas

你能在我的实际应用程序中使用百万美元标签生活我的原型(在Apache上运行,获取SSI)吗?

1 个答案:

答案 0 :(得分:0)

问题在于我没有逃避&#34;&amp;&#34;按照此处的建议(Escaping the & character)。 我的链接如下:

<a href="index.html?seccion=asignaturas&amp;area=materiales-editar" th:href="@{/asignaturas/{idAsignatura}/seccion/{idSeccion}/materiales/registro.html(idAsignatura=${asignatura.id},idSeccion=${asignatura.idSeccion},idfuncion=${param.idfuncion},idmodulo=${param.idmodulo})}"><i class="fa fa-plus-circle"></i> Registrar material</a>

现在我没有任何错误。谢谢!