不可以这样写
因为${...}这样的语法是EL表达式,与
<%...%>这样的scriptlet表达式是不同的,所以不能通用
如果你的view.getStatus()中的view是<c:forEach 中的varStatus属性的值,那么,你可以用这这样的写法表示<c:if test="${view.index==1}">或是<c:if test="${view.count==1}">.
因为${...}这样的语法是EL表达式,与
<%...%>这样的scriptlet表达式是不同的,所以不能通用
如果你的view.getStatus()中的view是<c:forEach 中的varStatus属性的值,那么,你可以用这这样的写法表示<c:if test="${view.index==1}">或是<c:if test="${view.count==1}">.
解决方案 »
- 如何操作执行中servlet中的对象?
- 关于session和cookie的一点疑问
- 请各位网友解释javascript语句的作用(标号为1.2.3.4)
- 谁能给我一个用java写的bbs系统
- 我写的jsp程序 还没写完 但是出现 问题 大家给我看看吧 谢谢,里面有异常的报告和代码 ,就一点点谢谢
- 小问题(页面)!!!在线!!!
- 我的机器既要做asp项目又要做jsp项目,我该选择哪一种配置方案呢?
- JBuilder里怎么配置Tomcat?
- 从mysql数据库中取得的数据排序问题~
- 如何实现下面的功能???
- jsp调用socket的问题:access denied。附代码
- 一个表达式.请各位朋友帮忙看看,急用.
<c:if test="${<%view.getStatus()==1%>}">
是正确的,但应该在view前面加=
这样<c:if test="${<%=view.getStatus()==1%>}">
然后这么写
<c:if test="${view.status==1}">
....
..</c:if>
The function getStatus must be used with a prefix when a default namespace is not specified
请问是怎么回事
<%@ 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>%>
不能在<%%>前后加${}!
<%
SoView view=(SoView)(result.get(5));
%>
<c:if test="<%=view.getStatus()==1%>">
....
</c:if>
错误有两个 一:<c:if >....</c:if>不能放在<%%>中
二:${...}中间变量值只能是通过page,Request、Session、Application得到
<%@ 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;
}
}
如果上面的代码还不能运行,那我真的没话说了