【spring】spel表达式
格式:
#{ }
简单使用实例
一、DButil.java
代码实现:
package springboottest.ioc.speltest;public class DBUtil {private UserService us;public UserService getUs() {return us;}public void setUs(UserService us) {this.us = us;} }
二、UserService.java
代码实现:
package springboottest.ioc.speltest;public class UserService {}
三、配置文件
代码实现:
<bean id="userService" class="springboottest.ioc.speltest.UserService"></bean><bean id="DBUtil" class="springboottest.ioc.speltest.DBUtil"><property name="us" value="#{userService}"></property></bean>
总结:
可以看到我们在使用自定义类时不用再使用ref引用,和基本类型一样使用value即可
注:这只是一个小例子,其中的调用框架错误的。
通过spel引用对象中的属性
一、constant.java
代码实现:
package springboottest.ioc.speltest;public class Constant {public String ENCODING = "utf-8";
}
二、DBUtil.java
代码实现:
package springboottest.ioc.speltest;public class DBUtil {private String constant;public String getConstant() {return constant;}public void setConstant(String constant) {this.constant = constant;}public void printConstant() {System.out.println("=======>" + constant);}
}
三、配置文件
<bean id="constant" class="springboottest.ioc.speltest.Constant"></bean><bean id="dbutil" class="springboottest.ioc.speltest.DBUtil"><property name="constant" value="#{constant.ENCODING}"></property></bean>
通过spel调用方法
一、constant.java
代码实现:
public class Constant {public String ENCODING = "utf-8";public String getNumber() {return "2354";}
}
二、DBUtil.java
代码实现:
package springboottest.ioc.speltest;public class DBUtil {private String constant;private String number;public String getNumber() {return number;}public void setNumber(String number) {this.number = number;}public String getConstant() {return constant;}public void setConstant(String constant) {this.constant = constant;}public void printConstant() {System.out.println("=======>" + constant);}public void printNumber() {System.out.println("======>" + number);}
}
三、配置文件
代码实现:
<bean id="constant" class="springboottest.ioc.speltest.Constant"></bean><bean id="dbutil" class="springboottest.ioc.speltest.DBUtil"><property name="number" value="#{constant.getNumber()}"></property></bean>
相关文章:

distinct吃亏记
distinct 是一个去掉重复数据的函数 1.此函数只能在 头部 2.此函数声明后。如果跟两个或两个以上的字段。则会导致。此函数去判断与两个字段都相同的。 例如ID为2 的字段有两个。但是这两个字的的创建时间不同。所有当你想通过DISTINCT ID,CREATTIME来把其中一个ID给筛选的话是…

input 选择框改变背景小技巧
最近在项目中遇到一个问题,想要改变input选择框的背景,然而,令我没有想到的是,竟然无法直接改变背景的颜色 通常情况下:我们都可以通过改变元素的 background-color 的值来改变元素的背景,但是在input选择框…

[转]Android JNI使用方法
本文转自:http://www.open-open.com/lib/view/open1324909652374.html 经过几天的努力终于搞定了android JNI部分,下面将我的这个小程序和大家分享一下。android JNI是连接android Java部分和C/C部分的纽带,完整使用JNI需要Java代码和C/C代码…

【spring】使用eclipse在没网时编写配置文件无法获取提示 解决方法
获得xsd文件 1、打开maven的目录 2、按照该顺序找到spring-context的目录 3、选择最新版本的进入 4、找到context的jar包 5、解压到存放xsd文件的文件夹(自己建立) 6、按照该顺序进入目录 7、将xsd文件放到cpfhxsd文件的文件夹 将xsd文件配置到ecipse中…

P4568 [JLOI2011]飞行路线
P4568 [JLOI2011]飞行路线 Description Alice和Bob现在要乘飞机旅行,他们选择了一家相对便宜的航空公司。该航空公司一共在n个城市设有业务,设这些城市分别标记为0到n-1,一共有m种航线,每种航线连接两个城市,并且航线有…

拿到淘宝offer后的胡思乱想plus面试总结
没想到能拿到淘宝的实习offer,心里还是很激动的。 大三以后就忙着找实习,参加了SAP和淘宝的校招,呵呵,还好,第二次就拿到了offer,剩下还有腾讯和百度的招聘,决定去看看,但是还是要走…

Map与List数据操作
为避免与数据库的多次连接,减少数据库的压力,先将所有的订货数据先从数据库中抽取出来,而后再将数据按门店进行分类汇总以备待用,Map与List混合操作,理解数据结构。提神醒脑哦。以下是原始数据结构:[{store…

《Java虚拟机规范》阅读(三):Class文件格式
每一个Class都对应着唯一的一个类或借口的定义信息。这里,我们称为"Class文件格式"只是通俗的将任意一个符合有效的类或借口的格式这么称呼,但是它并不一定是以磁盘文件的形式存在。 每个Class文件都是由8字节为单位的字节流组成,所…

【spring】自动装配
山顶洞人方法:aotowire UserDao.java 代码实现: public class UserDao {private DBUtil dbu;public DBUtil getDbu() {return dbu;}public void setDbu(DBUtil dbu) {this.dbu dbu;}public void test() {System.out.println(dbu);} }DBUtil.java 代…

扩展jquery实现客户端表格的分页、排序
下面链接中是我用jQuery的扩展来实现的表格分页和排序,使用这个扩展必须加上表头<thead>和<tbody>标签,因为我是 通过<tbody>来进行分页的,要是不加thead,那么表头也要作为分页计算时的一个行了。 下载最新代码…

Win7中如何删除word模板
Win7中如何删除word模板 计算机→本地磁盘c盘→用户→Administrator→AppData→Roaming→Microsoft→Templates转载于:https://blog.51cto.com/ilanni/555302

Spring 学习笔记
Spring 的 Ioc 容器所有的组件都是被动的( Passive),所有的组件初始化和调用都由容器负责。组件处在一个容器当中,由容器负责管理。BeanFactory 根据配置文件确定容器中 bean 的实现,管理 bean 之间的依赖关系。通常&a…

【spring】初识aop(面向切面编程) 使用jdk动态代理
BankServiceIImple.java 代码实现: package com.zzxtit.aop;import java.math.BigDecimal;public interface BankServiceImple {public void transfer(String source, String target, BigDecimal money);public void withdraw(String account, BigDecimal money);…

sigaction
#include <signal.h> int sigaction(int signum, const struct sigaction *act,struct sigaction *oldact); struct sigaction { void (*sa_handler)(int); void (*sa_sigaction)(int, siginfo_t *, void *); sigset_t sa_mask; int sa_flags; void …

003本周总结报告
本周对java的循坏结构和条件语句以及switch分支进行了复习并通过九九乘法表和制作日历来更加熟练使用和理解循环,并用eclipse替代了记事本来编写程序,同时针对记事本编写java程序后台运行出现的GBK不可映射字符问题先后采用了 javac -encoding UTF-8 …

HDU-1203 I NEED A OFFER!-0、1背包及空间优化
I NEED A OFFER! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5280 Accepted Submission(s): 1799Problem DescriptionSpeakless很早就想出国,现在他已经考完了所有需要的考试,准备了…

docker监控系统
第一:docker监控系统之命令行式监控 第二:docker监控系统之cadvisor 第三:docker监控系统之 第四:docker监控系统之 转载于:https://www.cnblogs.com/fengjunhua/p/8968210.html

Visual Studio 2005 Team System下载地址
注册一个msn就可以去微软下载了,关于替换序列号变成正版的方法我没有试,team suite我在用,但Team Foundation Server 我还没有安装好Microsoft Visual Studio 2005 简体中文正式版Visual Studio 2005 Team Suite 180 天试用版(可更换key变为正…

【spring】springAop开发
xml开发方式 springboot的使用 1、声明一个parent 代码实现: <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.2.0.RELEASE</version><relati…

使用 SqlHelperParameterCache 类管理参数
SqlHelperParameterCache类是位于 Microsoft.ApplicationBlocks.Data命名空间底下。它底下有三个方法,分别是: CacheParameterSet:用于将SqlParameters 数组存储到缓存中GetCachedParameterSet:用于检索读取缓存中SqlParameters数…

改善C#程序的建议6:在线程同步中使用信号量
所谓线程同步,就是多个线程之间在某个对象上执行等待(也可理解为锁定该对象),直到该对象被解除锁定。C#中对象的类型分为引用类型和值类型。CLR在这两种类型上的等待是不一样的。我们可以简单的理解为在CLR中,值类型是…

Jerry眼中的SAP客户数据模型
本文Jerry将介绍八款SAP产品中的客户模型。希望您在阅读完本文之后,能对SAP客户模型设计的思路有一个最最粗浅的了解。 由于Jerry水平和精力所限,本文不会详细阐述这些产品里的客户模型设计细节,而是介绍了一种方法,如果您对这些模…

【spring】spring JDBC开发 、 将创建表生成sql语句的方法
将navicate中已存在表的创建转化成sql语句的方法 1、右击表,选择对象信息 2、点击DDL jar包引入 1、spring-starter-jdbc 代码实现: <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-star…

PL/SQL ——分页编程
通过PL/SQL编程,编写分页存储过程。代码如下所示: 1 --PL/SQL开发编写分页代码 2 --创建包 3 create or replace package Page as 4 type test_cursor is ref cursor 5 end Page; 6 --创建存储过程 7 create or replace procedure Page( 8 (tablenam…

My view towards Machine Learning
Introduction:[to be continued]转载于:https://www.cnblogs.com/JVKing/articles/2290780.html

两个表的更新、表的复制
update 表1 set from 表1,表2 where 条件 表的复制数据 1.select * into newtable from table 2.insert into table select table2 select identity(int,1,1),* into newtable from .. 这条语句有时挺管用的转载于:https://www.cnblogs.com/leshang/archive/2…

Java数据结构简述
1、数组 概念:一个存储元素的线性集合。 数组声明和创建: dataType[] arrayRefVar new dataType[arraySize]; 二维数组(多维数组)声明和创建: dataType[][] arrayName new dataType[arraylenght1][arraylenght2]; PS…

CORS漏洞利用检测和利用方式
CORS全称Cross-Origin Resource Sharing, 跨域资源共享,是HTML5的一个新特性,已被所有浏览器支持,不同于古老的jsonp只能get请求。 检测方式: 1.curl访问网站 curl https://www.huasec.com -H "Origin: https://test.com…

【spring】具名参数
具名参数 配置xml文件 1、配置dataSource(数据源) 代码实现: <context:property-placeholderlocation"DB.properties"></context:property-placeholder><bean id"dataSource"class"com.alibaba.d…

利用委托和泛型实现树的常用操作
在日常开发中,经常遇到对树的操作,我们可以利用泛型和委托对这些树进行操作,这样就不需要每有一个树就要实现相应的功能了。 源码在http://files.cnblogs.com/haiconc/LangTest.zip 首先,使用类泛型声明: public class…