Comparing numbers in EL expression does not seem to work

后端 未结 2 525
栀梦
栀梦 2020-12-11 06:59

In JSP, I want to compare two variables

If I do:


 8}\">
  

        
2条回答
  •  没有蜡笔的小新
    2020-12-11 07:19

    You're hardcoding the value in the value attribute of . The treats the hardcoded values as String. EL is therefore also evaluating them as String. Lexicographically, 9 is greater than 10, because 9 is at a further numerical position than 1.

    There are two ways to solve this:

    1. Set the value via an EL expression. It will be interpreted as Long instead of String.

      
       
      
    2. Or, use , which would be the only solution if you have those as String variables from elsewhere which you have no control over.

      
      
      

提交回复
热议问题