不可以这样写
因为${...}这样的语法是EL表达式,与
<%...%>这样的scriptlet表达式是不同的,所以不能通用
如果你的view.getStatus()中的view是<c:forEach 中的varStatus属性的值,那么,你可以用这这样的写法表示<c:if test="${view.index==1}">或是<c:if test="${view.count==1}">.

解决方案 »

  1.   

    不好意思,我说错了,更正一下你的
    <c:if test="${<%view.getStatus()==1%>}">
    是正确的,但应该在view前面加=
    这样<c:if test="${<%=view.getStatus()==1%>}">
      

  2.   

    先确保在session/paeg/request/app..范围内,有这个bean变量
    然后这么写
    <c:if test="${view.status==1}">
    ....
    ..</c:if>
      

  3.   

    楼上的兄弟,照你们说的做了,可会出现如下错误
    The function getStatus must be used with a prefix when a default namespace is not specified
    请问是怎么回事
      

  4.   

    以下是我的代码
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ page import="com.pos.model.InfoGether,com.pos.view.SoView" %>
    <%@ page import="com.pos.model.InfoGether,com.pos.view.UserView" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%
    SoView view=(SoView)(result.get(5));
             <c:if test="${view.getStatus()==1}">
                  ....
             </c:if>%>
      

  5.   

    <c:if test="<%=view.getStatus()==1%>">
    不能在<%%>前后加${}!
      

  6.   


    <%
    SoView view=(SoView)(result.get(5));
    %>
    <c:if test="<%=view.getStatus()==1%>">
                  ....
    </c:if>
    错误有两个 一:<c:if >....</c:if>不能放在<%%>中
               二:${...}中间变量值只能是通过page,Request、Session、Application得到
      

  7.   

    <%@ page contentType="text/html; charset=GBK" %>
    <%@ page import="com.pos.model.InfoGether,com.pos.view.SoView" %>
    <%@ page import="com.pos.model.InfoGether,com.pos.view.UserView" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%
    SoView view=(SoView)(result.get(5));
             <c:if test="${view.getStatus()==1}">
                  ....
             </c:if>%>
    ---><%@ page contentType="text/html; charset=GBK" %>
    <%@ page import="com.pos.model.InfoGether,com.pos.view.SoView" %>
    <%@ page import="com.pos.model.InfoGether,com.pos.view.UserView" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%
    SoView view=(SoView)(result.get(5));
       %>      
             <c:if test="${view.status==1}">
                  ....
             </c:if>给个简单的例子:
    index.jsp<%@ page import="com.business.ComJstl" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%
        ComJstl com=new ComJstl();
        com.setUsername("yuhua");
        request.setAttribute("com",com);
    %>
        <c:if test="${not empty com.username}">
          <c:out value="${com.username}" />
        </c:if>
         com.business.ComJstlpackage com.business;/**
     * @author Bluewater
     *
     */
    public class ComJstl {
        
        public ComJstl(){
            
        }    private String username="";
        private String password="";
        
        /**
         * @return 返回 password。
         */
        public String getPassword() {
            return password;
        }
        /**
         * @param password 要设置的 password。
         */
        public void setPassword(String password) {
            this.password = password;
        }
        /**
         * @return 返回 username。
         */
        public String getUsername() {
            return username;
        }
        /**
         * @param username 要设置的 username。
         */
        public void setUsername(String username) {
            this.username = username;
        }
    }
    如果上面的代码还不能运行,那我真的没话说了