相关文章推荐
追风的投影仪  ·  bash shell ...·  9 月前    · 
无邪的扁豆  ·  System.getProperty("os ...·  11 月前    · 
八块腹肌的眼镜  ·  git pre-commit中npm: ...·  1 年前    · 
帅气的松球  ·  node.js - ...·  1 年前    · 
痴情的油条  ·  postgresql loop ...·  1 年前    · 

thymeleaf按钮跳转页面

Thymeleaf是一个用于生成HTML页面的模板引擎,可以方便地实现页面跳转。

如果你想要在一个Thymeleaf页面中创建一个跳转按钮,可以使用以下代码:

<a th:href="@{/anotherPage}">Go to another page</a>

其中,th:href是Thymeleaf的一个指令,用于设置链接的目标地址。@{/anotherPage}表示要跳转到另一个页面,该页面的路径为/anotherPage

如果你想要创建一个按钮,可以将上述代码放入一个button元素中:

<button th:onclick="location.href='@{/anotherPage}'">Go to another page</button>

其中,th:onclick是Thymeleaf的一个指令,用于设置按钮的点击事件处理函数。location.href='@{/anotherPage}'表示在点击该按钮后,将页面跳转到/anotherPage

  •