How to use thymeleaf conditions - if - elseif - else

后端 未结 6 1184
遇见更好的自我
遇见更好的自我 2021-02-07 20:04

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条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 20:20

    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

提交回复
热议问题