当前位置: 首页 > news >正文

免费建立手机网站营销型网站和普通网站

免费建立手机网站,营销型网站和普通网站,工程公司名称大全简单大气,怎么看网站做没做推广SpringEL bean引用实例 文章目录 SpringEL bean引用实例介绍Spring EL以注解的形式Spring EL以XML的形式 介绍 在Spring EL,可以使用点(.)符号嵌套属性参考一个bean。例如,“bean.property_name” public class Customer {Value("#{addressBean.c…

SpringEL bean引用实例

文章目录

  • SpringEL bean引用实例
    • 介绍
    • Spring EL以注解的形式
    • Spring EL以XML的形式

介绍

在Spring EL,可以使用点(.)符号嵌套属性参考一个bean。例如,“bean.property_name”

public class Customer {@Value("#{addressBean.country}")private String country;
}

在上面的代码片段,它从"addressBean""bean注入了"country"属性到现在的"customer"类的"country"属性的值

Spring EL以注解的形式

使用 SpEL 引用一个bean,bean属性也它的方法

package com.yiibai.core;import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component("customerBean")
public class Customer {@Value("#{addressBean}")private Address address;@Value("#{addressBean.country}")private String country;@Value("#{addressBean.getFullAddress('yiibai')}")private String fullAddress;//getter and setter methods@Overridepublic String toString() {return "Customer [address=" + address + "\n, country=" + country+ "\n, fullAddress=" + fullAddress + "]";}}
package com.yiibai.core;import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component("addressBean")
public class Address {@Value("GaoDeng, QiongShang")private String street;@Value("571100")private int postcode;@Value("CN")private String country;public String getFullAddress(String prefix) {return prefix + " : " + street + " " + postcode + " " + country;}//getter and setter methodspublic void setCountry(String country) {this.country = country;}@Overridepublic String toString() {return "Address [street=" + street + ", postcode=" + postcode+ ", country=" + country + "]";}}

执行结果

Customer obj = (Customer) context.getBean("customerBean");
System.out.println(obj);

输出结果

Customer [address=Address [street=GaoDeng, QiongShang, postcode=571100, country=CN]
, country=CN
, fullAddress=yiibai : GaoDeng, QiongShang 571100 CN]

Spring EL以XML的形式

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd"><bean id="customerBean" class="com.yiibai.core.Customer"><property name="address" value="#{addressBean}" /><property name="country" value="#{addressBean.country}" /><property name="fullAddress" value="#{addressBean.getFullAddress('yiibai')}" /></bean><bean id="addressBean" class="com.yiibai.core.Address"><property name="street" value="GaoDeng, QiongShang" /><property name="postcode" value="571100" /><property name="country" value="CN" /></bean></beans>
http://www.dinnco.com/news/27415.html

相关文章:

  • 宁波专业网站制作服务网络营销和电子商务区别
  • wordpress incategory网站排名优化多少钱
  • 威海做网站的公司有哪些网站页面seo
  • 建网站建设最近的新闻大事20条
  • 营销型网站建设特点恢复正常百度
  • 购物网站排名2016考研比较厉害的培训机构
  • 做照片书的模板下载网站好全国最好的广告公司加盟
  • 怎样做网站推广啊百度竞价什么时候开始的
  • 网站打开时的客户引导页深圳营销型网站
  • 珠海网站建设排名友情链接交换软件
  • 网站开发费用税网络营销主要做些什么工作
  • 怎样接做网站的活百度商城
  • 搜维斯网站建设seo任务平台
  • 哪家网站荥阳网站优化公司
  • 深圳燃气公司电话95511中国十大seo公司
  • 用商标做网站名字优化百度seo
  • 做细胞激活的母液网站国家新闻最新消息今天
  • 图片网站 模板如何提高网站的自然排名
  • ecshop怎么做网站推广手段和渠道有哪些
  • 微信小程序怎么写seo怎么做整站排名
  • 东莞专业全网推广建站公司种子搜索引擎
  • 响应式网站文字大小seo技术网
  • java做的网站怎么调试郑州seo团队
  • 德尔普网站建设长沙网站优化推广
  • 目前网站在初级建设阶段 需要大量数据丰富2022年最新新闻播报稿件
  • 那个比特币网站可以做杠杆品牌词优化
  • 做网站公司logo查看关键词被搜索排名的软件
  • 西安网评论seo企业推广案例
  • wordpress投稿验证码灯塔网站seo
  • 黑龙江网站建设工作室沈阳seo优化排名公司