摘要: Spring Security借助于一系列Servlet Filter来提供各种安全功能。 DelegatingFilterProxy是一个特殊的Servlet,它本身所做的工作并不多,只是将工作委托给 Javax.Servlet.Filter实现类,这个实现类作为一个<bean>注册在Spring 阅读全文
posted @ 2021-01-14 19:58 _Shing 阅读(198) 评论(0) 推荐(0)
摘要: import org.springframework.web.bind.annotation.ControllerAdvice;<!--more-->import org.springframework.web.bind.annotation.ExceptionHandler;/** * @vers 阅读全文
posted @ 2021-01-14 19:57 _Shing 阅读(123) 评论(0) 推荐(0)
摘要: 基于Java的初始化器创建组件(Servlet、Filter),最简单的方式就是实现Spring的WebApplication-Initializer。 package spittr.config;<!--more-->import org.springframework.web.WebApplic 阅读全文
posted @ 2021-01-14 19:56 _Shing 阅读(270) 评论(0) 推荐(0)
摘要: 7.2.1配置multipart解析器: DispatcherServlet没有实现Multipart请求数据的功能。<!--more-->它将该任务委托给MultipartResolver接口的实现来处理。Spring3.1开始为我们提供了两个解析类:StandardServletMultipar 阅读全文
posted @ 2021-01-14 19:55 _Shing 阅读(141) 评论(0) 推荐(0)
摘要: 如果配置了多个视图解析器,没有指定顺序,可以使用按照返回的名字匹配 package spittr.config;<!--more-->import org.springframework.context.annotation.Bean;import org.springframework.conte 阅读全文
posted @ 2021-01-14 19:54 _Shing 阅读(193) 评论(0) 推荐(0)
摘要: Spring MVC的校验 来自为知笔记(Wiz) 阅读全文
posted @ 2021-01-14 19:53 _Shing 阅读(111) 评论(0) 推荐(0)
摘要: 本章内容: 映射请求到Spring控制器 透明的绑定表单参数 校验表单提交 <!--more--> Spring MVC(模型model-视图view-控制器controller) 1.请求离开浏览器时,带着信息,url。 2.请求的第一站是DispatcherServlet前端控制器。Spring 阅读全文
posted @ 2021-01-14 19:52 _Shing 阅读(151) 评论(0) 推荐(0)
摘要: AOP好处: 1.把分散在各处的行为放入可重用的模块中。 2.减少代码冗余,并让我们的类专注于自己。 来自为知笔记(Wiz) 阅读全文
posted @ 2021-01-14 19:51 _Shing 阅读(138) 评论(0) 推荐(0)
摘要: package aspect;<!--more-->/** * @version 版权 Copyright(c)2019 * @ClassName: 表演接口 * @Descripton: * @author: Shing * @date: 2020-06-09 18:35 */public int 阅读全文
posted @ 2021-01-14 19:47 _Shing 阅读(169) 评论(0) 推荐(0)
摘要: execution( * concert.Performance.perform(..) ) execution 在方法执行时触发 * 返回任意类型 concert.Performance.perform 方法所属的类+方法名 .. 使用任意参数 execution( * concert.Perfo 阅读全文
posted @ 2021-01-14 19:46 _Shing 阅读(144) 评论(0) 推荐(0)
摘要: 当我们需要处理一些共同的业务时(事务、安全),我们可以使用继承的方式来实现。但是继承往往导致了一个脆弱的体系。切面提供了取代继承的另外一种方案。在很多场景下更清晰明了。 切面的好处: 1.每一个关注点都可以集中在一个地方。而不是分散在多处代码中。 2.服务代码更简洁,因为它们只包含主要关于点(或核心 阅读全文
posted @ 2021-01-14 19:45 _Shing 阅读(577) 评论(0) 推荐(0)
摘要: spring提供两种在运行时求值的方式。 属性占位符(Property placeholder) spring表达式语言(SpEl) 通过声明属性源并通过Spring的Enviroment来检索属性 Spring Environment的方法 String getProperty(String ke 阅读全文
posted @ 2021-01-14 19:44 _Shing 阅读(144) 评论(0) 推荐(0)
摘要: Spring定义了多种作用域,可以基于一下作用域创建bean: 单例(Singleton):在整个应用中,只创建一个bean实例。默认这种。 原型(Prototype):每次注入获取通过上下文获取时,创建一个新的bean实例。 会话(Session):在web应用中,为每个会话创建一个bean实例。 阅读全文
posted @ 2021-01-14 19:43 _Shing 阅读(101) 评论(0) 推荐(0)
摘要: 3.3.2限定自动装配的bean(@Qualifier 与@autowired配合使用) @Qualifier("bean的名称") 来自为知笔记(Wiz) 阅读全文
posted @ 2021-01-14 19:42 _Shing 阅读(112) 评论(0) 推荐(0)
摘要: 解决多个环境下数据库配置。 @Profile("dev"):在spring3.1中profile只能在累上使用,spring3.2之后就可以在方法上使用了(也就是一个类中可以配置多个了) <beans profile="dev" /> <beans profile="prod" /> spring. 阅读全文
posted @ 2021-01-14 19:41 _Shing 阅读(130) 评论(0) 推荐(0)
摘要: 在使用了@bean注解下的可以使用@Conditional注解实现条件化的bean,满足条件创建bean。 @Conditional(实现类.class) 在spring4中出现。而且profile在spring4中使用conditional重构 来自为知笔记(Wiz) 阅读全文
posted @ 2021-01-14 19:41 _Shing 阅读(156) 评论(0) 推荐(0)
摘要: @Import(CDCONFIG.class) / @Import({A.class,B.class}) 在javaconfig中引入javaconfig @ImportRsource("classpath:cd-config.xml") 在javaconfig中引入xml 如果引入的文件中有被使用 阅读全文
posted @ 2021-01-14 19:40 _Shing 阅读(120) 评论(0) 推荐(0)
摘要: <?xml version="1.0" encoding="UTF-8"?><!--more--><beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://www.springframework.org/sc 阅读全文
posted @ 2021-01-14 19:38 _Shing 阅读(108) 评论(0) 推荐(0)
摘要: @Configuration:表明这是个配置类,该类应该包含在spring应用上下文中。如果@Bean修饰的方法被 @Configuration修饰,那么方法是单例的。 @Bean:注解会告诉spring这个返回返回一个对象。该对象要注册为spring应用上下文中的bean,方法体中 包含了最终产生 阅读全文
posted @ 2021-01-14 19:35 _Shing 阅读(160) 评论(0) 推荐(0)
摘要: Spring从两个角度来实现自动化装配: 组建扫描(component scanning):@ComponentScan默认会扫描与配置类相同的包与该包的子包。查找 带有@Component注解的类并为其创建bean。 @Component:被扫描到会创建bean。 自动装配(autowried): 阅读全文
posted @ 2021-01-14 19:33 _Shing 阅读(109) 评论(0) 推荐(0)
摘要: 忽略,限制和排序查询选项1 db.reviews.find({'product_id':product['_id']}).skip(0).limit(12).sort({'helpful_votes':-1}) 1 1 db.reviews.find({'product_id':product['_ 阅读全文
posted @ 2021-01-14 19:30 _Shing 阅读(168) 评论(0) 推荐(0)