How to have a if with two conditions in Struts2

前端 未结 2 1022
我在风中等你
我在风中等你 2021-01-05 19:03

I iterate through a list of items, and need to show a specific dropdown list if the state of element is equal to student or teacher. The following code shows all fields but

2条回答
  •  难免孤独
    2021-01-05 19:57

    Put %{} around the whole expression, not in the middle as in other attributes of other tags:

    Also use a more appropriate equality function for Strings, like described here

    
    

    EDIT: dude, you are doing a lot of odd things;

    1. ${Status} is JSP EL, you have no need of using it;
    2. You are iterating a source, and checking another source: printing gives you an empty result, and I can't see that elements thing anywhere in your code;
    3. the capital letter as first in an attribute is WRONG, because if the variable is named foo and the getter is getFoo(), in page you will have .foo, not .Foo. If your variable is named Foo, it is against the specs / best practices, let's start variables names with a lowercase letter.

    Then If you have private Object Status, change it to private Object status;, along with the getter and the setter, and in page use:

    
        
    

    or with a var

    
        
    

    or simply

    
        
    

    Strange code leads to weird results... then use it straight :)

提交回复
热议问题