search

Home  >  Q&A  >  body text

javascript - thymeleaf template How to generate labels in a loop with only length?

The parameter of module is a number. How to use this number to generate a fixed number of labels in a loop?

習慣沉默習慣沉默2744 days ago694

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-27 17:42:29

    I understand your question is like this
    Input: a number
    Output: loop to generate a fixed label based on the size of the number, the number of labels is determined by the size of the number

    If this is the case, you may need to use the built-in function of thymeleaf: #numbers.sequencethymeleaf的内置函数了:#numbers.sequence
    这个方法就是根据传入的参数生成一个数列,类似于javaforThis method generates a sequence based on the parameters passed in, similar to < Code>java's for loop is the same, supporting two parameters and three parameters
    Parameter 1: starting value (inclusive)
    Parameter 2: end value (inclusive)
    Parameter three: step size

    Give me an example~
    java代码传入一个lengthParameters

    The page is looping like this

    Final effect:

    Of course, if you want to generate fixed labels, you don’t need to worry about the loop bodyi
    Similar to this

    reply
    0
  • Cancelreply