我有这个奇怪的问题,我试图读取一个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表达式不平衡"异常,我想知道为什么"}"one_answers"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>