zoukankan      html  css  js  c++  java
  • J2EE 第四周(03.26-04.01)

    1.分析hello.java

    /**
     * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
     *
     * You may not modify, use, reproduce, or distribute this software except in
     * compliance with  the terms of the License at:
     * https://github.com/javaee/tutorial-examples/LICENSE.txt
     */
    package javaeetutorial.hello1;
    
    
    import javax.enterprise.context.RequestScoped;
    import javax.inject.Named;
    
    @Named
    @RequestScoped
    public class Hello {
    
        private String name;
    
        public Hello() {
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String user_name) {
            this.name = user_name;
        }
    }

      代码具体地址:https://github.com/javaee/tutorial-examples/blob/master/web/jsf/hello1/src/main/java/javaeetutorial/hello1/Hello.java

    Hello类叫做管理bean类,它为facelets页面表达式所使用的name属性提供了getter和setter方法,默认该facelets页面表达式引用的是Hello类的名字,不过第一个字母是小写字母(例如:hello.name)。

            如果你使用的是默认的bean类的类名,你注解可以用@Model来替代@Named和@RequestScoped。@Model注释称为原型,是一个包含其他注释的注释的术语。

           在 Hello.java类中,注解javax.inject.Named和javax.enterprise.context.RequestScoped使用请求scope来标识Hello类为管理bean类。scope定义应用程序数据是如何保存和共享的。

          在JSF中最常用的scope如下:

                     Request(@RequestScoped):请求scope在Web应用程序中的单个HTTP请求期间仍然存在。像hello1应用,该应用由单个请求和响应组成,bean使用请求scope。

                     Session (@SessionScoped):会话scope持续存在于Web应用程序中的多个HTTP请求中。当应用程序包含需要维护数据的多个请求和响应时,bean使用会话scope。 

                     Application (@ApplicationScoped):应用程序scope在所有用户与Web应用程序的交互中持久存在。

    文章来源:http://www.cnblogs.com/zgq0/p/8685612.html

    2.

  • 相关阅读:
    数据库 的几种链接 join
    eclipse 无法记住svn密码
    loadrunner监控linux服务器
    谷歌浏览器跨域命令行方式失效
    努力学习的意义到底在哪里?(转载知呼上的答案)
    人的性欲为什么会被视为坏事?(转载)
    npm下载速度太慢
    使用systemback制作Ubuntu自定义系统镜像和系统备份(抄)
    使用bat脚本永久激活Windows系统(摘抄)
    fiddler软件测试——Fiddler抓取https设置详解(图文)(摘抄)
  • 原文地址:https://www.cnblogs.com/cactus20/p/8707254.html
Copyright © 2011-2022 走看看