Map value of object existing in session to jsp page

Hello everyone, I have an object in my session and I want to select the radio input type according to the attribute of my object. I tried the struts 2 taglib if tag and it doesn't work. here is part of my code

  <div class="form-group">
            <label class="col-sm-2 control-label">Admin </label> <label
                class="radio-inline">
                <div class="choice">
                    <s:if test="%{#session.curentprofil.isAdmin == N}">
                        <span><input type="radio" name="isAdmin" id="isAdmin"
                            class="styled" value="O" /></span>
                    </s:if>
                </div> O
            </label> <label class="radio-inline"> <span><input
                    type="radio" name="isAdmin" id="isAdmin" checked="checked"
                    class="styled" value="N" /></span> N
            </label>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">Admin </label> <label
                class="radio-inline">
                <div class="choice">
                    <s:if test="%{#session.curentprofil.isAdmin == O}">
                        <span><input type="radio" name="isAdmin" id="isAdmin"
                            class="styled" value="O" checked="checked" /></span>
                    </s:if>
                </div> O
            </label> <label class="radio-inline"> <span><input
                    type="radio" name="isAdmin" id="isAdmin" class="styled" value="N" /></span>
                N
            </label>
        </div>

      

+3


source to share


1 answer


Try the following:

<s:if test="#session.curentprofil.isAdmin == \"N\"">
   <!-- your code here -->
</s:if>

      



  • removed curly braces
  • highlighted symbol - see documentation [1]

[1] https://struts.apache.org/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html

+2


source







All Articles