How to use thymeleaf conditions - if - elseif - else

后端 未结 6 1420
刺人心
刺人心 2021-02-07 19:44

I have a little problem, I must return a different choice of a select into a td using thymeleaf, I try the next sentence:



        
6条回答
  •  猫巷女王i
    2021-02-07 20:14

    You conditional operator contains 3 results. It should have 2 like this.

    condition ? first_expression : second_expression;
    

    In your situation. I assume linea.estado is a boolean value

    
        
        
    
    

    If you want 3 values to be output and given that the linea.estado is a string which may contain 'WARN', 'DANGER', 'INFO' then you can do something like this.

    
    
    

    But the cleaner solution will be something like this

    
    
    
    

    Or using Switch as mentioned by Patrick LC

    • be aware of syntax errors, as I didnt test any codes on runtime

提交回复
热议问题