2018-05-02

JSF

资料
http://cf.jd.com/pages/viewpage.action?pageId=104237515
JSF是基于一种以组件为中心的UI构建方法,从而简化了Java服务器端应用程序的开发。(查下什么叫组件化)

了解一个系统(Java Web)所用的技术或者说了解一个系统的技术框架最直接的办法就是看他的web.xml文件,因为在java web领域任何一种技术都是依托于JavaEE这个标准来做的。也就是说他的目录结构都应该是类似下面这样的(图找找...)所以说一切附加的框架都会体现在web.xml当中。

JavaEE的前端框架都需要一个“入口”,Struct2的入口是拦截器 Struct和SpringMVC的入口是Servlet JSF的入口是“FaceServlet”

官方文档的原话是FaceServlet is a servlet that that manages the request processing lifecycle for web application that utilizing JavaServer Faces to construct the user interface.

servlet就是管理需求 下面写一个例子 两个界面 一个需要用户输入 另一个显示欢迎界面
hello.xhtml

<?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:f="http://java.sun.com/jsf/core"  
    xmlns:h="http://java.sun.com/jsf/html">  
  
<h:head>  
    <title>JSF 2.0 Hello World</title>  
</h:head>  
<h:body>  
    <h3>JSF 2.0 Hello World Example - hello.xhtml</h3>  
    <h:form>  
        <h:inputText value="#{helloBean.name}"></h:inputText>  
        <h:commandButton value="Welcome Me" action="welcome"></h:commandButton>  
    </h:form>  
</h:body>  
</html>  

welcome.xhtml

<?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:f="http://java.sun.com/jsf/core"  
    xmlns:h="http://java.sun.com/jsf/html">  
  
<h:head>  
    <title>JSF 2.0 Hello World</title>  
</h:head>  
<h:body bgcolor="white">  
    <h3>JSF 2.0 Hello World Example - welcome.xhtml</h3>  
    <h4>Welcome #{helloBean.name}</h4>  
</h:body>  
</html>  
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容