el

jsp的EL表达式¥{}

痞子三分冷 提交于 2020-03-01 08:18:44
搜索变量,搜索范围是 page、request、session、application。 EL 是从 JavaScript 脚本语言得到启发的一种表达式语言,它借鉴了 JavaScript 多类型转换无关性的特点。在使用 EL 从 scope 中得到参数时可以自动转换类型,因此对于类型的限制更加宽松。 Web 服务器对于 request 请求参数通常会以 String 类型来发送,在得到时使用的 Java 语言脚本就应该是 request.getParameter(“XXX”) ,这样的话,对于实际应用还必须进行强制类型转换。而 EL 就将用户从这种类型转换的繁琐工作脱离出来,允许用户直接使用 EL 表达式取得的值,而不用关心它是什么类型。 下面的示例就是一个 EL 表达式,见例 1 。 例 1 :简单 EL 表达式 <%@ page contentType="text/html; charset=UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> ${sampleValue + 1} <br> </body> </html> 这个示例将在 JSP 页面显示为“ 1 ”, EL 表达式必须以“ ${XXX} ”来表示,其中“ XXX ”部分就是具体表达式内容,“

jsp 页面EL 表达式不可用

痞子三分冷 提交于 2020-03-01 07:48:27
在JSP2.0中,增加了EL语言,可以通过EL语言,实现获取数据,进一步将script代码从JSP页面中分离出来.EL语言给大家带来了方便,但有时,也会遇到EL表达式不能显示的情况,下面,我将列举几种EL表达式不 能显示的情况及解决方案: 1.WEB-INF/web.xml,web应用的部署描述文件引用的是servlet规范的2.3版本或更早的版本(即jsp1.2或更早),则jsp2.0表达式语言自动在web应用中停用。2.3版本xml指令和文档类型定义如下: <!-- 2.3版本即jsp1.2 jsp2.0表达式语言自动停用 --> <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> 如果是2.4版本,则为: <!-- 2.4版本即jsp2.0 表达式语言可用 --> <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org

Passing string parameter to a function or method from xhtml

放肆的年华 提交于 2020-01-30 05:26:11
问题 I have a button that I'd like to render based on whether a function returns true or false. The HTML: <p:commandButton type="button" rendered="#{myBean.checkPermission(1)}" value="Create" /> And the supporting bean: public boolean checkPermission(String actionKey) { ... } The problem is that when I call checkPermission with a numeric parameter like #{myBean.checkPermission(1)} , it works fine, but with I pass a String as a parameter, i.e. #{myBean.checkPermission(ABC)} , I get an empty string

Nesting variables in EL

送分小仙女□ 提交于 2020-01-28 11:23:09
问题 Is it possible to nest variable calls like below in EL using FacesContext or other implicit objects like request , session , etc.? This of course is not working. I get this error Error Parsing: #{myBean.myMethod(#{FacesContext.getCurrentInstance().getViewRoot().getViewId() })} for this attempt <ui:include src="#{myBean.myMethod(#{FacesContext.getCurrentInstance().getViewRoot().getViewId() })}"> 回答1: This is indeed invalid EL syntax. Nesting of #{} is disallowed. Just put the whole expression

Setting a validator attribute using EL based on ui:repeat var

China☆狼群 提交于 2020-01-28 01:55:24
问题 I am looking for a little bit of guidance today with the issue I am running into. What I am trying to accomplish is build a page on the fly with validation and all. The end result is to allow the user to configure the fields on the page through administrative functions. Below is a copy of the code that I am using as the test page where I loop through the "Configured" fields and write out the fields using the defined criteria. <ui:repeat var="field" value="#{eventMgmt.eventFields}" varStatus=

Format a date and display it using JSTL and EL

為{幸葍}努か 提交于 2020-01-24 02:23:06
问题 How do I format and display a Date object in a JSP, most preferably using JSTL and EL but any other solution is welcome? I can not change the bean object. I have the following class: import java.util.Date; public class Person { private Date myDate; public Date getMyDate() { return myDate; } public void setMyDate(Date myDate){ this.myDate = myDate; } } I am trying to display the date in this object in a JSP page. When I do this <c:out value="${person.myDate} /> it prints this in the page. 2013

Set HTML dropdown selected option using JSTL

无人久伴 提交于 2020-01-20 14:35:11
问题 In the same context i have another query <select multiple="multiple" name="prodSKUs"> <c:forEach items="${productSubCategoryList}" var="productSubCategoryList"> <option value="${productSubCategoryList}"${productSubCategoryList == productSubCategoryName ? 'selected' : ''}>${productSubCategoryList}</option> </c:forEach> </select> and the corresponding setting in request is like for(int i=0;i<userProductData.size();i++){ String productSubCategoryName=userProductData.get(i).getProductSubCategory(

Change fmt:formatDate pattern dynamically

扶醉桌前 提交于 2020-01-15 09:06:30
问题 I need to change fmt:formatDate pattern dynamically depending on the localization. I have the property file for each locale with the date.format key, somewhere it's value is MM/dd/YYYY, somewhere DD/MM/YYYY and so on. In the JSP I have the following tag: <fmt:formatDate value="${dateToFormat}" pattern="<spring:message code='date.format' />" var="formattedDate" /> The Exception I get is java.lang.IllegalArgumentException: Illegal pattern character 'p' What's wrong with this code? 回答1: Looks

Programmatically register taglib reference

偶尔善良 提交于 2020-01-15 04:12:46
问题 Is there a way to programmatically, in a java code, register custom taglib reference? I am using JSF 1.2_09, rich faces 3.3.3, jsf-facelets 1.1.14. Specifically: In this code, jsf Expression Language is used to do some job for us, like concatenation of 2 results in one field or similar stuff.. FacesContext ctx = FacesContext.getCurrentInstance(); Application app = ctx.getApplication(); ExpressionFactory ef = app.getExpressionFactory(); ELContext elContext = ctx.getELContext(); ValueExpression

<c:if test= > is always true

依然范特西╮ 提交于 2020-01-13 08:42:09
问题 I am stuck with the following code. On a JSP page, I want to write different things depending on the terminal the browser is accepted on. the terminal value is set properly in the controller but when executing the following code, all the 3 c:if conditions are considered valid and the three sentences are displayed <c:if test="${terminal=='android'}"> <p>you are on android</p> </c:if> <c:if test="${terminal=='iphone'}"> <p>you are on iphone </p> </c:if> <c:if test="${terminal=='other'}"> <p>you