相关文章推荐
奋斗的乒乓球  ·  vue.js - ...·  1 年前    · 
发怒的小蝌蚪  ·  MultipartFile ...·  1 年前    · 
大方的烤地瓜  ·  Code First ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams Is it the "greater-than", angley bracket that you don't like? If so, you can use gte in place of >= in OGNL - commons.apache.org/ognl/language-guide.html rees Sep 18, 2012 at 19:59 I had some issues with the code, and wondered if this should work as expected on a var that is numeric? user1628194 Sep 18, 2012 at 20:39

The angle bracket i.e > is legal inside the if struts tag. From the link shared by @rees, under the section Appendix: OGNL Language Reference > Operators , you can see this example:

e1 >= e2, e1 gte e2
Greater than or equals comparison

In your case:

<s:if test="%{#someVar gte 60}">Hello</s:if>

and you don't need the %{}, as the # sign is already telling Struts to go and find the someVar on the ActionContext. Better still, you don't need the # sign, if someVar is on the Value Stack, i.e declared as a property in your Action class with getter and setter.

This does not work though:
<s:if test="%{#someVar &gte; 60}">Hello</s:if>

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.