2020
09-24
09-24
Springboot工程中使用filter过程解析
一、什么是filter过滤器实际上就是用来对web资源进行拦截,做一些处理后再交给下一个过滤器或servlet处理通常都是用来拦截request进行处理的,也可以对返回的response进行拦截处理。filter可以在请求到达servlet前或者请求完成响应后进行后续的处理。二、在springboot工程中使用filter创建一个filter,并使用注解配置该filter的名称和拦截路径等属性@WebFilter(filterName="AFilter",urlPatterns="/*")publicclassAFilteri...
继续阅读 >
首先创建一个邮箱账号,建议@126.com,@163.com,@qq.com都可以开启smtp,以下是使用图解:创建SpringBoot项目导入依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--支持发送邮件--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId></depen...
1.使用springboot项目,现在有个需求是在添加或者修改某个菜单后,菜单会影响角色,角色影响用户。所有受影响的用户在要退出重新登录。自己实现的思路是这样的:写一个监听器,在收到某个特定的请求后,监听当前所有的用户,如果是受影响的用户,就销毁session,让重新登录。有了思路后,刚开始上网搜的是怎么在springboot中添加监听:网上大部分的思路都一样:使用@ServletComponentScan和一个实现了HttpSessionListener的方法就...
一、用户名密码都正确的情况下被登录拦截器拦截控制台报错:org.apache.ibatis.executor.ExecutorException:AquerywasrunandnoResultMapswerefoundfortheMappedStatement'com.spbt.mapper.EmpeeMapper.selectName'.It'slikelythatneitheraResultTypenoraResultMapwasspecified.这个异常是在mapper文件的<select>标签中没有指定resultType或者resultMap,也就是说没有指定返回值类型或者返回值类型...
我们先来看代码:@ConfigurationpublicclassWebMvcConfigextendsWebMvcConfigurationSupport{publicFastJsonHttpMessageConverterfastJsonHttpMessageConverter(){FastJsonHttpMessageConverterfastJsonHttpMessageConverter=newFastJsonHttpMessageConverter();FastJsonConfigfastJsonConfig=newFastJsonConfig();//todo这里进行配置,空和null,不返回fastJsonConfig.setSerializerFeatures(...
如果我们使用过SpringBoot,那么就会对下面的图案不陌生。Springboot启动的同时会打印下面的图案,并带有版本号。查看SpringBoot官方文档可以找到关于banner的描述Thebannerthatisprintedonstartupcanbechangedbyaddingabanner.txtfiletoyourclasspathorbysettingthespring.banner.locationpropertytothelocationofsuchafile.IfthefilehasanencodingotherthanUTF-8,youcansetsprin...
:>使用Springinitialier需要配置文件POM文件复制代码代码如下:<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.1</version></dependency><dependency><groupId>org.springframework.boot</groupI...
静态页面的return默认是跳转到/static/目录下,当在pom.xml中引入了thymeleaf组件,动态跳转会覆盖默认的静态跳转,默认就会跳转到/templates/下,注意看两者return代码也有区别,动态没有html后缀。1.1在static下新建hello1.html运行程序,浏览器输入http://localhost:8080/hello1.htmlso,可以在根目录下访问hello1.html,static目录类似于传统Javaweb中的webroot或webcontent1.2也可以通过接口跳转1.2.1添加接口@RequestMapp...