摘要: 一、SpringMVC输出模型数据的几种常见途径 1、ModelAndView @Controller public class SpringmvcDemo { @RequestMapping(value = "/testModelAndView", method = RequestMethod.G 阅读全文
posted @ 2020-09-01 23:54 变体精灵 阅读(1155) 评论(0) 推荐(1) 编辑
摘要: 1、@RequestParam 注解的作用是可以将请求参数绑定到控制器的处理方法的形参上,我们可以通过下面测试案例得出该注解具体的作用 2、@RequestParam 注解源码 @Target({ElementType.PARAMETER}) @Retention(RetentionPolicy.R 阅读全文
posted @ 2020-09-01 20:07 变体精灵 阅读(708) 评论(0) 推荐(0) 编辑
摘要: 一、REST概述 REST:即Representational State Transfer,也就是(资源)表现层状态转化. REST是目前最流行的一种互联网软件架构,它结构清晰、符合标准、易于理解、扩展方便,所以正得到越来越多网站的采用REST. 1、资源(Resources):网络上的一个实体, 阅读全文
posted @ 2020-08-31 23:59 变体精灵 阅读(409) 评论(0) 推荐(0) 编辑
摘要: 一、@RequestMapping注解的作用 浏览器发起请求,被DIspatcherServlet截获请求之后,通过控制器上面的@RequestMapping注解提供的相关信息,来确定处理请求的具体方法. 该注解可以标记在类上:提供初步的请求映射信息,相对于WEB应用的根目录. 该注解可以标记在方法 阅读全文
posted @ 2020-08-31 20:03 变体精灵 阅读(247) 评论(0) 推荐(0) 编辑
摘要: SpringMvc之HelloWorld搭建步骤: 一、导包 spring-context-5.2.8.RELEASE.jar spring-aop-5.2.8.RELEASE.jar spring-beans-5.2.8.RELEASE.jar spring-context-5.2.8.RELEA 阅读全文
posted @ 2020-08-27 23:47 变体精灵 阅读(189) 评论(0) 推荐(0) 编辑
摘要: @Value注解和@PropertySource注解配合使用可以将(*.properties)配置文件中的内容动态的注入到实体类中.具体步骤如下: 1、自定义实体类(Person.java) // 对象注入Spring容器中,交由Spring进行管理 @Component // 加载classpat 阅读全文
posted @ 2020-08-25 19:02 变体精灵 阅读(719) 评论(0) 推荐(0) 编辑
摘要: Bean的生命周期主要包括:创建 >初始化 >销毁 这几个过程,Spring中有很多管理Bean的生命周期的方式,下面我们就列举几种常用的. 一、通过@Bean注解指定 1、自定义Bean public class Person { private String name; private int 阅读全文
posted @ 2020-08-25 15:16 变体精灵 阅读(143) 评论(0) 推荐(0) 编辑
摘要: @Import注解是用于给Spring容器导入组件,其主要的使用方式有下列三种 一、@Import 1、@Import注解的详细信息如下: @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented public 阅读全文
posted @ 2020-08-24 14:01 变体精灵 阅读(452) 评论(0) 推荐(0) 编辑
摘要: 一、@Conditional 注解简介 @Conditional 注解是 Spring4 新提供的注解,它的作用是按照一定的条件进行判断,如果满足条件给 IOC 容器注入相应的 bean @Conditional 注解源码如下: // 该注解可以标注在 类、接口、枚举声明、方法上 @Target({ 阅读全文
posted @ 2020-08-20 23:41 变体精灵 阅读(547) 评论(0) 推荐(0) 编辑
摘要: 一、@Scope注解详细信息如下: @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Scope { // scopeNa 阅读全文
posted @ 2020-08-20 20:18 变体精灵 阅读(224) 评论(0) 推荐(0) 编辑