zoukankan      html  css  js  c++  java
  • java ee 4周

     1 /**
     2  * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
     3  *
     4  * You may not modify, use, reproduce, or distribute this software except in
     5  * compliance with  the terms of the License at:
     6  * https://github.com/javaee/tutorial-examples/LICENSE.txt
     7  */
     8 package javaeetutorial.hello1;
     9 
    10 
    11 import javax.enterprise.context.RequestScoped;
    12 import javax.inject.Named;
    13 
    14 @Named
    15 @RequestScoped
    16 public class Hello {
    17 
    18     private String name;
    19 
    20     public Hello() {
    21     }
    22 
    23     public String getName() {
    24         return name;
    25     }
    26 
    27     public void setName(String user_name) {
    28         this.name = user_name;
    29     }
    30 }

    @Named是Bean的名称,若没有指定,则默认和类名相同。

    @RequestScoped用于指定一个bean的请求范围。就是在每次请求服务器过程中会保存输入值,点击xxx.xhtml页面对应的提交按钮我们发现新页面当中的提交次数永远是1,也就是说RequestScoped的范围就是在从请求开始到请求结束,如果再次请求那么数据将被更新。

    定义了一个实体类,实体类的方法是getter和setter方法,属性是private类型,以及一个构造函数

  • 相关阅读:
    【BZOJ1006】神奇的国度(弦图)
    弦图
    【BZOJ2946】公共串(后缀数组)
    【POJ1743】Musical Theme(后缀数组)
    JAVA和Tomcat运维整理
    linux shell 之if-------用if做判断
    Linux curl命令详解
    Intel HEX文件解析
    Linux bridge-utils tunctl 使用
    怎样查询锁表的SQL
  • 原文地址:https://www.cnblogs.com/MeiT/p/8688732.html
Copyright © 2011-2022 走看看