context

spring之为什么要使用事务?

落花浮王杯 提交于 2020-01-08 17:57:21
问题描述:现在我们有一个数据库:spring 三张表:account、book、book_stock account存储着用户以及账户余额。book存储着书号、名字和 购买一本所需金额。book_stock存储着书号以及对应的库存。 现在我们有这么一个需求: 用户买一本书,先让书的库存减一,然后在让用户余额减去相应的金额。 我们来看如何处理。 新建一个Java project,在项目下新建一个lib文件夹,在文件夹中加入以下包: 选中这些包,点击鼠标右键,选择build path,选择add to build path。 然后建立以下的目录结构: 一、配置连接数据库 db.properties jdbc.user=root jdbc.password=123456 jdbc.driverClass=com.mysql.jdbc.Driver jdbc.jdbcUrl=jdbc:mysql:///spring jdbc.initPoolSize=5 jdbc.maxPoolSize=10 在applicationContex.xml中 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org

数组中查找指定元素

北慕城南 提交于 2020-01-08 14:22:20
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> findIndex(es6) function isBigEnough(element) { return element >= 15; } [12, 5, 8, 130, 44].findIndex(isBigEnough); // 3 findIndex 会找出第一个大于 15 的元素的下标,所以最后返回 3。 实现findIndex function findIndex(array, predicate, context) { for (var i = 0; i < array.length; i++) { if (predicate.call(context, array[i], i, array)) return i; } return -1; } console.log(findIndex([1, 2, 3, 4], function(item, i, array){ if (item == 3) return true; })) // 2 findLastIndex function findLastIndex(array, predicate, context) { var length = array.length; for (var i = length - 1; i >= 0; i--)

SpringMVC

烂漫一生 提交于 2020-01-08 13:45:26
http://www.xxx.com?id=&type= Model:将传输数据封装成一个完整的整体 View:视图,用来展示或者输出的一个模块(HTML,JS,JSON,String,Swing,xml。。。 ) Control:控制交互的一个中间组件,由他来根据用户请求分发不同任务从而得到不同的结果 三者合在一起就叫做MVC,基于项目开发的设计模式,用来解决用户和后台交互的问题 J2EE标准,JSP页面是一个万能组件,可以写HTML,可以写JS,写java逻辑,写sql语句 MVC框架:Struts1,Struts2,WebWork,SpringMVC SpringMVC只是MVC设计模式的应用典范,给MVC的实现制定了一套标准 M:支持将url参数自动封装成一个Object或者Map V:自己只有一个默认的template,支持扩展,自定义View,而且能够自定义解析 C:能够把限制放宽了,任何一个类,都有可能是Controller 在dispatcherServlet中onRefresh方法 protected void onRefresh(ApplicationContext context) { initStrategies(context); } /** * Initialize the strategy objects that this servlet uses.

SpringApplication认识

怎甘沉沦 提交于 2020-01-08 13:44:24
SpringApplication SpringApplication Spring Boot 驱动Spring应用上下文的引导类 @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan( excludeFilters = {@Filter( type = FilterType.CUSTOM, classes = {TypeExcludeFilter.class} ), @Filter( type = FilterType.CUSTOM, classes = {AutoConfigurationExcludeFilter.class} )} ) public @interface SpringBootApplication { ......... } @ComponentScan是Spring FrameWork3.1版本开始引入的 @EnableAutoConfiguration:激活自动装配 @Enable->@Enable开头的(Enable开头的取个名字叫激活模式) @EnableWebMvc @EnableTransactionManagement @EnableAspectJAutoProxy @EnableAsync @SpringBootConfiguration:等价于

HTML5 Canvas标签及基本使用

淺唱寂寞╮ 提交于 2020-01-08 10:04:48
< canvas>定义图形 基于状态进行绘制的 大多数 Canvas 绘图 API 都没有定义在 < canvas> 元素本身上, 而是定义在通过画布的 getContext() 方法获得的一个“绘图环境”对象上 canvas . width canvas . height //指定canvas的宽高 canvas . getContext ( "2d" ) ; //返回绘制的环境 context . moveTo ( 10 , 10 ) //从(10,10)开始画 context . lineTo ( 100 , 100 ) //从(10,10)开始画,画到(100,100) context . stroke ( ) //开始绘制(线条) context . lineWidth = 3 //设置线条的宽度 context . strokeStyle = "#f00" 设置线条的颜色 stroke笔画的意思 context . fillStyle = "rgb(255,0,0)" ;context . fill ( ) //着色,,填充的颜色(颜色块) context . beginPath ( ) ; //定义一个新的路径 context . closePath ( ) ; //用在路径结束, 如果绘制的路径不是封闭的则会自动封闭起来,不写closrPath则不会封闭 //从坐标

JavaEE 之 Spring(一)

南笙酒味 提交于 2020-01-08 08:27:15
1.Spring   a.作用:降低组件与组件之间的关联,便于系统的维护和拓展   b.核心思想:     ①IOC:控制反转——配置文件依赖注入     ②AOP:面向切面编程 2.IOC/DI   a.建配置文件 <?xml version="1.0" encoding="UTF-8"?> <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" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop

小程序-demo:小程序示例-page/api

不问归期 提交于 2020-01-08 05:40:41
ylbtech-小程序-demo:小程序示例-page/api 以下将演示小程序接口能力,具体属性参数详见小程序开发文档。 1. page/component 返回顶部 1、 a) .js Page({ data: { list: [ { id: 'api', name: '开放接口', open: false, pages: [ { zh: '微信登录', url: 'login/login' }, { zh: '获取用户信息', url: 'get-user-info/get-user-info' }, { zh: '发起支付', url: 'request-payment/request-payment' }, { zh: '分享', url: 'share/share' }, { zh: '客服消息', url: 'custom-message/custom-message' }, { zh: '模板消息', url: 'template-message/template-message' } ] }, { id: 'page', name: '界面', open: false, pages: [ { zh: '设置界面标题', url: 'set-navigation-bar-title/set-navigation-bar-title' }, { zh:

Spring学习

我们两清 提交于 2020-01-08 00:50:39
一、IOC(控制反转)   Spring的控制反转:把对象的创建、初始化、销毁等工作交给spring容器来做。   1.spring容器创建对象的方式     1)默认是调用默认的构造函数 <bean id=“personService" class="cn.itcast.bean.impl.PersonServiceImpl"/>     2)利用静态工厂方法创建 <bean id="personService" class="com.itcast.factory.PersonServiceFactory" factory-method="createPersonService" /> public class PersonServiceFactory { public static PersonService createPersonService(){ return new PersonServiceImpl(); } }     3)实例工厂方法:比较少用,有些开源项目会用。      说明:spring配置文件中,只要是一个bean就会为该bean创建对象   2. spring容器创建对象的时机     在单例的情况下:       1)在默认的情况下,启动spring容器创建对象       2)在spring的配置文件bean中有一个属性lazy-init=

React23Hooks钩子之useContext

只谈情不闲聊 提交于 2020-01-07 22:11:50
context就是用来更方便的实现全局数据共享的,但是由于它并不是那么好用,所以我们一般会使用第三方状态管理器来实现全局数据共享 redux dva mobx useContext(context)是针对context上下文提出的一个Hooks提出的一个API,它接收React.createContext()的返回值作为参数,即context对象,并返回最近的context 使用useContext是不需要再使用Provide和Consumer的 当最近的context更新时,那么使用该context的hook将会重新渲染 基本使用如下: 详细示例: 最常用的方法: 《1》创建一个store文件夹管理这些共享数据 《2》在需要使用共享数据的组件比如UseContext组件中引入然后作为参数传入useContext中。单一数据来源。 来源: https://www.cnblogs.com/tengfeiS/p/12154361.html

asp.net 知识回顾(三)

不羁岁月 提交于 2020-01-07 16:02:02
在之前的文章介绍过HttpModule,在这就不啰嗦了。 今天完成了一个小案例,效果如图: 为原有的文本,添加一些其它信息,实现思路如下: 一、创建TestHttpModule类,并实现IHttpModule接口。 二、实现IHttpModule接口中的方法,为HttpApplication对象的BeginRequest事件绑定方法,实现在用HttpHandler处理每个请求前,附加额外信息的功能。 namespace HttpModule_Demo.App_Code { public class TestHttpModule : IHttpModule { public void Dispose() { } public void Init(HttpApplication context) { context.BeginRequest += Context_BeginRequest; context.EndRequest += Context_EndRequest; } private void Context_EndRequest(object sender, EventArgs e) { HttpApplication application = sender as HttpApplication; application.Response.Write("<p