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

深圳市建设中心官网网址百度seo优化工具

深圳市建设中心官网网址,百度seo优化工具,wordpress 网页内嵌,舆情监测平台SpringEL初始 文章目录 SpringEL初始什么是SpringELSpring BeansSpring EL以XML形式Spring EL以注解形式启用自动组件扫描 执行输出 什么是SpringEL Spring EL与OGNL和JSF EL相似,计算评估或在bean创建时执行。此外,所有的Spring表达式都可以通过XML或注…

SpringEL初始

文章目录

  • SpringEL初始
    • 什么是SpringEL
    • Spring Beans
    • Spring EL以XML形式
    • Spring EL以注解形式
      • 启用自动组件扫描
    • 执行输出

什么是SpringEL

  • Spring EL与OGNL和JSF EL相似,计算评估或在bean创建时执行。此外,所有的Spring表达式都可以通过XML或注解
  • 我们将学习如何使用Spring表达式语言(SpEL),注入字符串,整数,Bean到属性,无论是在XML和注释

Spring Beans

两个简单Bean,后来利用 SpEL 注入值到属性,在 XML 和 注释。

public class Customer {private Item item;private String itemName;}
public class Item {private String name;private int qty;}

Spring EL以XML形式

  • 使用 SpEL关闭的#{ SpEL expression }括号,请参阅XML bean定义文件下面的例子
<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="itemBean" class="com.yiibai.core.Item"><property name="name" value="itemA" /><property name="qty" value="10" /></bean><bean id="customerBean" class="com.yiibai.core.Customer"><property name="item" value="#{itemBean}" /><property name="itemName" value="#{itemBean.name}" /></bean></beans>
  1. #{itemBean} – 注入"itemBean"到"customerBean"Bean 的"item"属性。
  2. #{itemBean.name} – 注入"itemBean"的"name"属性到 “customerBean” bean的"itemname"属性。

Spring EL以注解形式

在注解使用使用SpEL,必须通过注解注册您的组件。如果注册bean在XML和Java类中定义@Value,该@Value将无法执行

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component("customerBean")
public class Customer {@Value("#{itemBean}")private Item item;@Value("#{itemBean.name}")private String itemName;//...}
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component("itemBean")
public class Item {@Value("itemA") //inject String directlyprivate String name;@Value("10") //inject interger directlyprivate int qty;public String getName() {return name;}//...
}

启用自动组件扫描

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><context:component-scan base-package="com.yiibai.core" /></beans>

在注解模式下,可以使用@Value定义Spring EL。在这种情况下,一个String和Integer值直接注入到“itemBean”,之后又注入“itemBean”到“customerBean”属性

执行输出

运行它,无论是使用 SpEL在XML 还是注释都显示了同样的结果:

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class App {public static void main(String[] args) {ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");Customer obj = (Customer) context.getBean("customerBean");System.out.println(obj);}
}

输出结果

Customer [item=Item [name=itemA, qty=10], itemName=itemA]
http://www.dinnco.com/news/14689.html

相关文章:

  • 苹果app开发工具seo优化技术
  • 编程工具成都网站建设seo
  • 惠州疫情最新消息2021seo需要掌握哪些技术
  • 网站建设进展推进表百度引流推广
  • wordpress 3.5 下载地址建站优化推广
  • 网站推广风险中国域名注册官网
  • 考试类网站如何做自动点击器app
  • 政府网站建设哪家好b站视频推广网站2023
  • 企业网站程序营销模式都有哪些
  • wordpress日志元代码百度荤seo公司
  • 昆明专业做网站多少钱aso优化违法吗
  • 网站怎么收录到百度北京网站优化企业
  • 万州网站制作公司深圳知名seo公司
  • 如何在工商局网站做身份确认优化网站seo方案
  • wordpress编辑器自动加p标签百度seo关键词点击软件
  • 网站别人帮做的要注意什么东西搜索引擎谷歌
  • 淮安做网站.哪家网络公司好怎么注册电商平台
  • 网站建设了流程seo评测论坛
  • wordpress分类页正版seo搜索引擎
  • 做网站需要执照嘛亚马逊alexa
  • 嘉定网站设计开发查询关键词排名软件
  • 团队展示网站销售管理
  • 独立ip做多个网站seo高手是怎样炼成的
  • wordpress vlturseo外包优化服务商
  • 保健品网站怎么做的爱站工具包官网下载
  • 海口双语网站建设查数据的网站有哪些
  • 直播网站怎样建设搜狗搜索网
  • 永久个人网站软件培训机构排名
  • wordpress子主题引用js铁力seo
  • 网站建设费怎么做账推广是什么意思