el

for循环list、取得索引值、定义变量、取出map中的value、if...else循环、日期

浪尽此生 提交于 2019-12-05 21:19:37
< %@taglib uri=" http://java.sun.com/jsp/jstl/core " prefix="c"%> <%@ taglib uri=" http://java.sun.com/jsp/jstl/functions " prefix="fn"%> <%@ taglib uri=" http://java.sun.com/jsp/jstl/fmt " prefix="fmt" %> 1、for循环list、取得索引值、定义变量、取出map中的value、if...else循环、日期格式化、空值判断、字符串函数 <c:forEach items="${tableNameVoList}" var="tableNameVar" varStatus="i" > <c:set var="tableNameTemp" value="${ tableNameVar.tableName }" scope="request" /> <!-- 判断是否展示表 --> <c:choose> <c:when test="${tableViewFlag[tableNameTemp] == true}"> <li><a href="#page_${i.index}" id="${i.index}">${tableNameVar.tableNameZh}</a></li> </c

JSPX EL 2.2 method calling using EL 2.1

泄露秘密 提交于 2019-12-05 19:34:22
I have JSP that works fine in Tomcat 7 but does not work in Tomcat 6 which I assume is the fact that you cannot call methods (other than getters/setter) from EL 2.1. The method I need to call cannot be named as a getter. I figured out a workaround and thought I would post the answer: If you have Spring installed you can use Spring EL so that you can call methods on objects For example: <spring:eval expression="pic.thumbnailUrl()" var="thumbnail" /> 来源: https://stackoverflow.com/questions/6194164/jspx-el-2-2-method-calling-using-el-2-1

How data travels in Struts2?

≡放荡痞女 提交于 2019-12-05 19:20:59
I am trying to understand the path data takes within Struts2, how is data placed on the ValueStack? How can I find out which object is currently present in the ValueStack? What other data can I access from different scopes application, session, request, page? How to decide the scopes my variables should have? Dave Newton That's a lot of questions. The value stack is just a data structure, sort of a combination of a map and stack. Named objects (accessed via the # tag in OGNL) are in the map (like the request scope, say), objects to search through for properties/methods are on the stack. The <s

JSPX namespaces not visible for EL functions?

岁酱吖の 提交于 2019-12-05 18:57:21
I'm attempting to use JSPX (pure XML syntax for JSP) and running into what seems like it should work, but doesn't. I'm importing taglibs using namespace declarations in the jsp:root element, then using these later on for elements as well as EL functions: <jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/ xmlns:c="urn:jsptld:/WEB-INF/tld/c.tld" xmlns:fn="urn:jsptld:/WEB-INF/tld/fn.tld"> ... <c:if test="${fn:length(list) > 0"> ... </c:if> ... </jsp:root> I get an exception saying "The attribute prefix fn does not correspond to any imported tag library". Other pages work fine, but this

JSF EL: instanceof reserved but not yet implemented?

大兔子大兔子 提交于 2019-12-05 18:10:32
问题 I've found the instanceof operator in JSF EL, but it throws an exception when used. It's obviously reserved but not implemented? When will it (probably) be available, if not already in a newer version than JSF 1.2, which I'm currently using? 回答1: The keyword instanceof is indeed reserved in the EL (see here), but it is still not used in the latest version of EL (2.2), used in JSF 2.x. 来源: https://stackoverflow.com/questions/5549999/jsf-el-instanceof-reserved-but-not-yet-implemented

javaweb开发之EL和JSTL

大兔子大兔子 提交于 2019-12-05 14:28:42
一、EL 1.概述 EL 全名为Expression Language。 EL表达式可用在所有的HTML和JSP标签中作用是代替JSP页面中复杂的JAVA代码。 EL主要作用如下: (1)获取数据: EL表达式主要用于替换JSP页面中的脚本表达式,以从各种类型的web域 中检索java对象、获取数据。(例如:某个web域 中的对象,访问javabean的属性、访问list集合、访问map集合、访问数组) (2)执行运算: 利用EL表达式可以在JSP页面中执行一些基本的关系运算、逻辑运算和算术运算,以在JSP页面中完成一些简单的逻辑运算。如:${user==null} (3)获取web开发常用对象 EL 表达式定义了一些隐式对象,利用这些隐式对象,web开发人员可以很轻松获得对web常用对象的引用,从而获得这些对象中的数据。 (4)调用Java方法 EL表达式允许用户开发自定义EL函数,以在JSP页面中通过EL表达式调用Java类的方法。 EL表达式是JSP 2.0规范中的一门技术 。因此,若想正确解析EL表达式,需使用支持Servlet2.4/JSP2.0技术的WEB服务器。 注意:当有些Tomcat服务器如不能使用EL表达式时: (1)升级成tomcat6; (2)在JSP中加入<%@ page isELIgnored="false" %>。 <%@ page

How to get session attribute with a dynamic key in EL?

烂漫一生 提交于 2019-12-05 10:11:38
问题 If I set session like this: <% session.setAttribute("taintedAttribute", "what ever we want"); %> normally we can get session variable like this in EL ${sessionScope.taintedAttribute } But how about if I want to do like this <% String name = "taintedAttribute"; //session.setAttribute(name, "what ever we want"); session.getAttribute(name); %> Then how can we call it in EL? Can EL get something like ${sessionScope.---dynamic name ---} ? If I do this: <c:set var="name" value="taintedAttribute" />

String to Long comparison throws “ELException: Cannot convert” in Tomcat 7, works in Tomcat 6

元气小坏坏 提交于 2019-12-05 09:09:41
The following snippet works fine in Tomcat 6, <c:set var="abc" value="$12,345" /> <c:choose> <c:when test="${abc ne 0}"> <c:out value="PASS"></c:out> </c:when> <c:otherwise> <c:out value="FAIL"></c:out> </c:otherwise> </c:choose> but throws exception in Tomcat 7. javax.el.ELException: Cannot convert $1,2345 of type class java.lang.String to class java.lang.Long at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:304) at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:283) at org.apache.el.lang.ELSupport.equals(ELSupport.java:143) at org.apache.el.parser.AstNotEqual

JSF 2.1 ValueExpression in action-attribute

时光怂恿深爱的人放手 提交于 2019-12-05 07:53:49
Section 3.1.4 of the JSF 2.1 Specification says that all attributes of standard components are value expression enabled . I want to assign a value expression to the action attribute of a commandButton: <h:commandButton value="OK" action="#{myBean.valExp}" /> I also defined corresponding getValExp and setValExp methods in the bean's class. However my JSF implementation (JBoss 6) takes that expression to be a method expression and thus yields a "method not found" error because there's no valExp()-method. Am I doing something wrong or is the specification just too sloppy and actually doesn't mean

JSF component binding - some confusion

╄→尐↘猪︶ㄣ 提交于 2019-12-05 07:17:38
From web pages like this one, http://www.jsftutorials.net/components/step5.html I understand that the binding attribute in JSF tag/view component is to bind the view component to a Java instance of the UI component in the backing bean. E.g., that's what is done in the following code: <h:inputText value="#{ myBean.someProperty}" binding="#{ myBean.somePropertyInputText}"/> But sometimes I see code like this : <h:commandButton id="t1" binding="#{foo}" value="Hello, World!" onclick="alert('I am #{id:cid(foo)}'); return false;" /> where id:cid is a taglib function which is defined as follow: