EL未在xhtml页面中评估

时间:2015-05-20 15:47:08

标签: jsf el

我正在尝试使用tomcat,maven运行jsf的helloworld示例。问题是  我的xhtml中的EL没有被评估,同样是在浏览器中打印#{hello.world}。

这是我的hello.xhtml代码:

<!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">

 <h:head>
  <title>Facelets</title>
 </h:head>
 <h:body>
  #{hello.world}
 </h:body>
</html>

这是我的Hello托管bean:

package com.xtream.managedbean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;


@ManagedBean(eager=true)
@SessionScoped
public class Hello {
 private String world = "Hello World!!!!!!!!";
public String getWorld(){
    return world;
}

}

这是我的web.xml文件:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      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>Archetype Created Web Application</display-name>
<servlet>
    <servlet-name>JavaServerFaces</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>JavaServerFaces</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>
        /faces/hello.xhtml
    </welcome-file>
</welcome-file-list>
</web-app>

提前致谢。

0 个答案:

没有答案