似乎速度和freemarker看起来相似,至少对于基本用法而言.
无论如何,什么是"内置"或标准视图框架?看起来像:
<c:if test="${someobject.property != null}">
Run Code Online (Sandbox Code Playgroud) 我有这个代码不起作用.
<jsp:useBean id="abbreviationlist" class="AbbreviationListType"/>
<jsp:setProperty name="abbreviationlist" property="id"/>
<table>
<c:forEach items="${abbreviationlist.list}" var="abbreviation">
</c:forEach>
</table>
Run Code Online (Sandbox Code Playgroud)
我有类AbbreviationListType with set和get方法list-get singnature is =
public List<AbbreviationType> getList()
Run Code Online (Sandbox Code Playgroud)
有谁可以请指出我做错了什么?因为这不起作用,我得到这个堆栈跟踪:
javax.servlet.jsp.PageContext.getELContext()Ljavax/EL/ELContext; java.lang.NoSuchMethodError:javax.servlet.jsp.PageContext.getELContext()Ljavax/EL/ELContex; 在javax.servlet.jsp.jstl.core.LoopTagSupport.unExposeVariables(LoopTagSupport.java:620).....................
这是我的WEB-INF/lib

和我的catalina/common/lib

有人可以帮助我,除了我有.
在servlet中,我将国家列表发送给jsp
request.setAttribute("countries", allCountryList);
Run Code Online (Sandbox Code Playgroud)
在jsp中我想在下拉列表中显示它们,我用来用foreachddl填充值
<c:forEach var="country" items="${requestScope.countries}" >
<option value="${country.countryNo}">${country.countryName}</option>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
奇怪的例外是,即使存在,countryName也不存在
javax.el.PropertyNotFoundException: Property 'countryName' not found on type ps.iugaza.onlineinfosys.entities.Country
Run Code Online (Sandbox Code Playgroud)
这是国家级
public class Country {
private String countryName;
private int countryNo;
public String getCoutnryName() {
return countryName;
}
public int getCountryNo() {
return countryNo;
}
}
Run Code Online (Sandbox Code Playgroud) 我尝试将参数传递给方法管理员,如下所示:
<p:toolbarGroup align="right" rendered="#{loginBean.admin('dataread'}">
<h:form>
<p:commandButton value="manage users" ajax="false"
icon="ui-icon-document" action="/admin/manageUsers.xhtml?faces-redirect=true"/>
</h:form>
</p:toolbarGroup>
Run Code Online (Sandbox Code Playgroud)
我托管Bean中的代码就是这样
public boolean isAdmin(String role){
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
return request.isUserInRole("admin");
}
Run Code Online (Sandbox Code Playgroud) <c:forEach items="${availableBadges}" var="badge">
<div>
<c:choose>
<c:when test="${badge} == ${user.activeBadge};">
Run Code Online (Sandbox Code Playgroud)
徽章是带有两个字符串字段的枚举.
用户具有正确的getter并返回Badge的实例.foreach工作正常,但我不能让synatx正确比较枚举?
在评估EL时,对#和$之间的区别有一个非常基本的问题.防爆.
<c:if test="#{bindings.value == true}">
Run Code Online (Sandbox Code Playgroud)
和
<c:if test="${bindings.value == true}">
Run Code Online (Sandbox Code Playgroud) EL语句在c:forEach循环中的视图构建时间内会发生什么。
<c:forEach var="v" values="#{bean.values}">
<p:inputText value="#{v.name}" />
</c:forEach>
class Bean {
public List<Pojo> getValues();
}
class Pojo {
public void setName (String);
public String getName();
}
Run Code Online (Sandbox Code Playgroud)
此代码将如何评估渲染?至:
<p:inputText value="John Smith">
Run Code Online (Sandbox Code Playgroud)
要么
<p:inputText value="#{pojo.name}" >
Run Code Online (Sandbox Code Playgroud) 我已尽可能多地检查,但我找不到问题所在,我看到很少有与我相关的堆栈溢出问题,但大多数似乎都缺少#.我已经看到某个地方,旧版本的mojora lib可能会导致这种例外.我检查名称我在hibernate bean中使用它们看起来都很好但是无法找到问题.....
我的Html页面:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:t="http://myfaces.apache.org/tomahawk">
<h:body>
<ui:composition template="/WEB-INF/templates/layout.xhtml">
<ui:param name="category" value="Admin" />
<ui:param name="item" value="Create User" />
<ui:param name="user" value="#{createUserAccountBean}" />
<ui:define name="content">
<h:form id="productsForm">
<div class="headerbg">
<div id="innerheaderbg">
<div id="iconarea">
<img src="#{request.contextPath}/images/headerimages/productlist.png" />
</div>
<div id="headertextarea">
<p class="headingtext">Order</p>
<p id="breadCrumbtext">Order  <img src="#{request.contextPath}/images/error-bullet.gif" />
 Product Category List
</p>
</div>
<div id="otherarea"></div>
</div>
</div>
<p:growl />
<div class="widget widget-table action-table">
<div class="widget-header"> <i class="icon-th-list"></i> …Run Code Online (Sandbox Code Playgroud) 我正在将托管bean注入另一个托管bean的托管属性.
package com.books.beans;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="book")
@RequestScoped
public class Book {
@ManagedProperty(value = "page")
private Page pages;
// Getter/setter
}
Run Code Online (Sandbox Code Playgroud)
package com.books.beans;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="page")
@RequestScoped
public class Page {
// ...
}
Run Code Online (Sandbox Code Playgroud)
但是,它抛出以下EL异常:
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/JSFTraining] threw exception [Unable to set property pages for managed bean book] with root cause
javax.el.ELException: Cannot convert page of type class java.lang.String to class com.books.beans.Page
at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:416)
at org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:46) …Run Code Online (Sandbox Code Playgroud) el ×10
jstl ×5
jsf ×4
java ×3
jsf-2 ×3
jsp ×3
enums ×1
expression ×1
javabeans ×1
managed-bean ×1
oracle-adf ×1
primefaces ×1
templates ×1
xml ×1
xml-parsing ×1