SpringBoot start

SpringBoot入门到精通

http://412887952-qq-com.iteye.com/blog/2291496

 

开发环境搭建:

1.eclipseIDE

2.eclipseIDE上安装插件Maven

3.eclipseIDE上安装插件Spring Tool Suite

 

相关资料:

Spring Boot官网:http://projects.spring.io/spring-boot/

Eclipse官网:http://www.eclipse.org/

Maven官网:http://maven.apache.org/

JDK下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html

Spring Tool Suite地址:http://spring.io/tools/sts/all

 

 

 

Spring Boot 启动时拦截器的使用和配置可参考以下内容: ### 使用方法 在 Spring Boot 中,拦截器依赖于 Spring 容器。在 Spring Boot 2.x 以后版本,拦截器会拦截静态资源,因此在配置时需要将静态资源放行。例如,在配置拦截器时,可通过 `addPathPatterns` 方法指定要拦截的路径,通过 `excludePathPatterns` 方法排除不需要拦截的路径,像登录页面、静态资源等路径就可排除在外。示例代码如下: ```java @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new PageInterceptor()).addPathPatterns("/**") .excludePathPatterns("/page/login","/user/login","/page/ajax","/static/**"); } ``` 这里的 `PageInterceptor` 是自定义的拦截器类,`addPathPatterns("/**")` 表示拦截所有路径,`excludePathPatterns` 中的路径则不会被拦截 [^1]。 ### 配置方式 配置拦截器需要创建一个配置类,继承 `WebMvcConfigurerAdapter`(若该类显示过期,则可继承 `org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport`),并在类上添加 `@Configuration` 注解。在该配置类中重 `addInterceptors` 方法,在方法里添加自定义的拦截器并指定拦截路径。示例代码如下: ```java package com.jy.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import yaycrawler.common.interceptor.SignatureSecurityInterceptor; @Configuration public class WebAppConfig extends WebMvcConfigurerAdapter { /** 添加拦截器 * WebMvcConfigurerAdapter 显示过期,则使用继承至org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport */ @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new MySignatureSecurityInterceptor()).addPathPatterns("/admin/**","/manager/**"); } } ``` 在上述代码中,`MySignatureSecurityInterceptor` 是自定义的拦截器类,`addPathPatterns("/admin/**","/manager/**")` 表示拦截以 `/admin/` 和 `/manager/` 开头的路径 [^4]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值