html - EL表达式不平衡jsf

标签 html css jsf

我有这个奇怪的问题,我正在尝试使用表达式语言读取 div 的宽度,div 在数据表中,这里是一个示例

<h:dataTable value="#{MyBean.List}" var="bean" id="active-list"> <div class="green-div" style="width: #{bean.ratio}px"></div> </h:dataTable>

但是当我在这里运行页面时会发生什么<h:dataTable value="#{MyBean.List}" var="bean" id="active-list"> <div class="green-div" style="width: #{bean.ratio"></div> </h:dataTable>

我得到“EL 表达式不平衡”异常,我想知道为什么“}”和“px”消失了。提前致谢

还有我的 web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>MyAPP</display-name>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/login.xhtml</location>
</error-page>
<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/errorPage.html</location>
</error-page>
<session-config><!-- Session timeout is set to 30 Mins -->
    <session-timeout>30</session-timeout>
</session-config>
<filter>
    <filter-name>Extensions Filter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>Extensions Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

    </web-app>

最佳答案

试试这个宽度

<h:dataTable value="#{MyBean.List}" var="bean" id="active-list">
    <div class="green-div" style="#{'width: '.concat(bean.ratio).concat('px')}"></div>
</h:dataTable>

关于html - EL表达式不平衡jsf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24054483/

相关文章:

javascript - bootstrap form-inline 无法使用 d3 正确渲染

html - 使用 libxml SAX 解析 HTML 片段

html - margin-left(以百分比设置)随着 Chrome 中的每个元素缩小(而不是在 Firefox 中)

html - 需要帮助自定义 Css 皮肤 Telerik 控件中的 CSS 伪元素

javascript - 如何在模糊功能之前执行点击功能

JSF 复合组件

javascript - 为什么我的 Canvas 无法正确清除?

html - 网页布局在不同屏幕上显示不同

jsf - javax.el.PropertyNotFoundException : The class doesn't have property

ajax - 具有多种形式的 JSF (PrimeFaces) 中的多个 AJAX 状态