ID

  • #ids: 处理可能重复(比如,由于迭代)的id属性的实用方法。
  1. /*
  2. * ======================================================================
  3. * See javadoc API for class org.thymeleaf.expression.Ids
  4. * ======================================================================
  5. */
  6. /*
  7. * Normally used in th:id attributes, for appending a counter to the id attribute value
  8. * so that it remains unique even when involved in an iteration process.
  9. */
  10. ${#ids.seq('someId')}
  11. /*
  12. * Normally used in th:for attributes in <label> tags, so that these labels can refer to Ids
  13. * generated by means if the #ids.seq(...) function.
  14. *
  15. * Depending on whether the <label> goes before or after the element with the #ids.seq(...)
  16. * function, the "next" (label goes before "seq") or the "prev" function (label goes after
  17. * "seq") function should be called.
  18. */
  19. ${#ids.next('someId')}
  20. ${#ids.prev('someId')}