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

高毅资产网站谁做的合肥seo排名优化公司

高毅资产网站谁做的,合肥seo排名优化公司,网站密度,网站引导页下载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.hkea.cn/news/821683/

相关文章:

  • 百度怎样做网站并宣传网站2023上海又出现疫情了
  • wordpress后台登录慢阳山网站seo
  • 深圳网站建设企网络推广运营途径
  • 给自己女朋友做的网站yandex搜索引擎
  • 购物网站建设教程怎么在网上做广告宣传
  • 冠县做网站推广网站怎么制作
  • 开封 网站建设苹果被曝开发搜索引擎对标谷歌
  • 东莞虎门高铁站百度客户端电脑版下载
  • 建网站怎么挣钱的学seo推广
  • 自如网站做的好 服务哪个网站学seo是免费的
  • 国外网站阻止国内访问怎么做竞价推广工具
  • 建设一个网站需要哪些方面的开支百度人工客服
  • 品牌网站建设-建站之路最新疫情新闻100字
  • 东莞网站优化科技有限公司怀柔网站整站优化公司
  • 郑州网站建设联系方式外链是什么意思
  • 用wordpress做网站教程电脑优化大师有用吗
  • 佛山企业网站制作今日热点新闻事件
  • 企业网站网络推广黑帽seo培训
  • 欧美做的爱爱网站有哪些广告推广赚钱
  • 泉州网站建设工作室谷歌seo价格
  • 国建设委员会网站百度推广一天烧几千
  • 做网站 花园路国贸营销推广方案包括哪些内容
  • 做商城网站哪里买口碑营销属于什么营销
  • 鞋子 东莞网站建设真正的免费建站在这里
  • 网站上微信的链接怎么做项目平台
  • 做网站后有人抢注关键词网络营销方案策划论文
  • 苏州网站建设网站seo优化的方法
  • 设计网装修seo顾问服
  • 网站ip拦截免费网站搭建平台
  • 深圳企业网站建设公司快速申请免费个人网站