Nav Kumar
Nav Kumar

Reputation: 141

if else not working on jstl

hiii i am using spring MVC and i have list which  ia m sending as my response to  jsp but ibn in this jsp i have a attribute isnew which is of type boolean so i want a comaprison on this attribute soo  sode is

    <core:forEach var="i" items="${loginsuccess}" >
        <core:if test="${i.isNew eq true}"> 
                <core:out value="${i.notofication}"></core:out> </br>   
                </core:if>
        </core:forEach>

DAO CODE

@Autowired
    SessionFactory usermanagementSessionFactory;

    public ModelAndView  getNotifications(int id){

        System.out.println("Method ios called");
        Session session = usermanagementSessionFactory.openSession();

        System.out.println("after Getting Session");
        int  id1  = id;
        System.out.println(id1);
        Query query=(Query) session.getNamedQuery("getNotification");
        query.setInteger("userId",id1);

        List<Message> list1= query.list();

        ModelAndView mv = new ModelAndView("notifications");

         mv.addObject("loginsuccess" ,list1);
        return mv;



}

 its not working please suggest me how can i resolve this problem 

to check how it works. i want to show the notification only when it is new , this is the dao code which returns the login success and controller only calling this code as a simple method

Upvotes: 0

Views: 136

Answers (2)

Lalit Nandan
Lalit Nandan

Reputation: 39

you can use like this

<c:choose>

   <c:when test="${i.new}"> 
//to do statement
   </c:when>
//to do statement
   <otherwise>

   </otherwise>
</c:choose>

Upvotes: 0

Alex
Alex

Reputation: 11579

This should work

<core:if test="${i.new}"> 

Upvotes: 1

Related Questions