【发布时间】:2014-06-05 07:45:51
【问题描述】:
我有一个奇怪的问题,我正在尝试使用表达式语言读取 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 Expression Unbalanced”异常,我想知道为什么“}”和“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>
【问题讨论】:
-
“运行页面”是什么意思?
-
我的意思是当我部署应用程序并在浏览器上打开页面时
-
如果您在运行页面时看到 facelets 代码,这意味着您的 FacesServlet 配置有问题。请发布您的 web.xml 文件,并告诉我们更多关于您的环境(容器、jsf 版本..等)
-
不,我没有看到任何 facelets 代码,我正在使用 weblogic,jsf2
-
您确实会在浏览器上看到 facelets 代码 (
<h:dataTable .../>)。这意味着您的 FacesServlet 配置错误。您在启动/部署应用程序时是否遇到任何错误?