EL的使用

来源:互联网 发布:数据存储单位 编辑:程序博客网 时间:2024/05/15 02:17

http://community.csdn.net/Expert/topic/4320/4320301.xml?temp=.4254419


参见struts1.1源代码/src/share/org/apache/taglib/logic/IterateTag.java
 // Store the first value and evaluate, or skip the body if none
        if (iterator.hasNext()) {
            Object element = iterator.next();
            if (element == null) {
                pageContext.removeAttribute(id);
            } else {
                pageContext.setAttribute(id, element);
            }
            lengthCount++;
            started = true;
            if (indexId != null) {
                pageContext.setAttribute(indexId, new Integer(getIndex()));
            }
            return (EVAL_BODY_TAG);
        } else {
            return (SKIP_BODY);
        }

中的pageContext(javax.servlet.jsp.PageContext)
可以用pageContext取到indexId的值
<%=(Integer)pageContext.getAttribute("indexid")%>

tomcat5下的web应用程序,默认情况下是不支持EL表达式的,如果你想使用EL表达式的话,需要做以下事情
方法一
            在每个jsp页面添加<%@ page isELIgnored="false" %>
方法二
            修改web.xml中的<web-app>标记为
            <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee-web-app_2_4.xsd" version="2.4">
这样就OK了