el

EL表达式的使用及编写和使用EL表达式的自定义函数

为君一笑 提交于 2019-12-10 05:29:22
什么是EL表达式 Expression Language————表达式语言 EL表达式的作用 获取数据 执行运算 获取Web开发常用对象 执行Java方法 获取数据: <% User user = new User("旺财", "幸福路", 18); pageContext.setAttribute("pageContextUser", user); request.setAttribute("requestUser", user); session.setAttribute("sessionUser", user); application.setAttribute("applicationUser", user); %> <h2>获取page域对象</h2> ${pageContextUser.name}----${pageContextUser.addr}-----${pageContextUser.age} <br/> ${pageScope.pageContextUser.name}----${pageScope.pageContextUser.addr}-----${pageScope.pageContextUser.age} <hr /> <h2>获取request域对象</h2> ${requestUser.name}----${requestUser.addr}-

JSP comparison operator behaviour

断了今生、忘了曾经 提交于 2019-12-10 03:43:54
问题 I want to compare two different types in <c:if> tag of JSP. Basically left one is Number always but right one is a String and If that string could be parse to a Number I receive no error but If the String cant be parsed to a Number I receive javax.el.ELException: Cannot convert No of type class java.lang.String to class java.lang.Long . Practically: ${1 =="" } //works fine ${1 =="4" } //works fine ${1 =="Yes" } //triggers the Exception. But even the 3rd comparison worked fine in previous

Mac OS X El Capitan 安装 Jekyll

老子叫甜甜 提交于 2019-12-10 03:15:36
安装Gem ## 检查gem版本 $gem -v ## 更新Gem(提示权限) $gem update --system 2.0.14 Latest version currently installed. Aborting. 安装jekyll El Capitan apple 修改了权限问题 使用以下命令安装 $ sudo gem install -n /usr/local/bin jekyll 等待一会儿,安装成功 $ jekyll -v jekyll 3.1.1 使用jekyll ## 博客生成,默认生成再_site目录下 $jekyll build $jekyll build--watch //自动检测编译 ## 开启jekyll本地预览 $jekyll server $jekyll serve --watch //自动运行编译文件 jekyll 相关依拉库 ,使用以下命令安装: sudo gem install -n /usr/local/bin XXXX 相关错误: ERROR: Could not find a valid gem 'jekyll' (>= 0), here is why: Unable to download data from https://rubygems.org/ - Errno::ECONNRESET: Connection reset

Managed property value not updated when both beans are of same scope

最后都变了- 提交于 2019-12-09 22:40:15
问题 I am seeing this strange behavior when using @ManagedProperty . I have 2 beans: UserManager (SessionScoped) @ManagedBean @SessionScoped public class UserManager extends BaseBean implements Serializable { private static final long serialVersionUID = 1861000957282002416L; private User currentUser; public String login() { // set value of currentUser after authentication } public User getCurrentUser() { return currentUser; } public boolean isLoggedIn() { return getCurrentUser() != null; } }

Get rid of that silly space eclipse generates when you open an EL expression

断了今生、忘了曾经 提交于 2019-12-09 15:54:20
问题 When I use an EL expression in Eclipse, I naturally begin by typing ${ . Eclipse, wanting to help out a little, places a close brace } afterward. However, there's a space between them. So if I want ${user.name} I type ${ , followed by user.name but my end result is ${user.name } - that extra space drives me bonkers. I've looked through all the menus and cannot find where this is defined. Clearly I haven't looked through well enough, because it has to be in there. How can I eliminate... no,

JSTL Expression Language accessing object properties

不想你离开。 提交于 2019-12-09 12:26:32
问题 I was following a tutorial today that had me scratching my head for an hour. Consider: public class MyClass { public int getTotal() { amount = 100; return amount; } } and an excerpt from a JSP: <p>Total: ${objectOfTypeMyClass.total}</p> //object instantiated elsewhere Nowhere in the code was an instance variable named " total " ever declared or used. The only reference to the word "total" in the whole project (other than in the JSP) was the method getTotal() . So after some desperate last

Expression Language & Eclipse warning: “items” does not support runtime expressions

拟墨画扇 提交于 2019-12-09 07:36:11
问题 i have the following JSP: <%@ page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ page isELIgnored="false"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><c:out value="${it.title}"/></title> </head> <body> <c:forEach var="speaker" items="${it.speakers}" varStatus="stat"> <ul> <li><c

JSF EL expressions to check empty string in propery file?

百般思念 提交于 2019-12-09 03:56:29
问题 I have to check if my property file is empty for certain label based on that I have to render the element but even when the label is empty i still get the element displaying key: <h:panelGroup rendered="#{not empty I18N['key_hint_message'] }"> <h:outputLabel id="hint_label" value="#{I18N['key_label_hint']} "></h:outputLabel> <h:outputText value="#{I18N['key_hint_message']}" ></h:outputText> </h:panelGroup> 回答1: You can use ResourceBundle#containsKey() for this. <h:panelGroup rendered="#{I18N

How to invoke JSF action on an anonymous class? EL cannot access it

落爺英雄遲暮 提交于 2019-12-08 23:51:31
问题 I want to have a generic menu in my JSF (MyFaces 1.2) application. <h:form> <h:dataTable id="dt1" value="#{portal.actionList}" var="item"> <f:facet name="header"> <h:outputText value="Menu" /> </f:facet> <h:column> <h:commandLink action="#{item.action}"> <h:outputText value="clickme"/> </h:commandLink> </h:column> </h:dataTable> </h:form> Then my portal on session-scope would look like this: class Portal { private ArrayList<IAction> list = new ArrayList<IAction>(); public Portal() { list.add

JSF: h:outputText; how to show a dash when the value is empty string?

自作多情 提交于 2019-12-08 23:18:07
问题 I'm using h:outputText tags to display readonly data. Ex: <h:outputText value="Phone Number:" /> <h:outputText value="#{userHandler.user.phoneNumber}" /> When "phoneNumber" is an empty string or a null, I want to display a dash "-" as the value. Is there any easy way to do this maybe with expression language or something? BTW, I thought about adding methods to the User class like getPhoneNumberDisplayText() that could do the check internally, but I since it's a view issue, I'd rather keep the