Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
8f375736
Commit
8f375736
authored
Mar 25, 2020
by
yuquan.zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
跨域
parent
89999286
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
src/main/java/cn/timer/api/config/interceptor/RedisSessionInterceptor.java
+18
-0
src/main/java/cn/timer/api/config/interceptor/WebSecurityConfig.java
+13
-8
No files found.
src/main/java/cn/timer/api/config/interceptor/RedisSessionInterceptor.java
View file @
8f375736
...
...
@@ -5,6 +5,8 @@ import java.io.IOException;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
...
...
@@ -12,12 +14,28 @@ import cn.hutool.json.JSONObject;
import
cn.timer.api.utils.ResponseResult
;
//拦截登录失效的请求
@Component
public
class
RedisSessionInterceptor
implements
HandlerInterceptor
{
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
// response.setHeader("Access-Control-Allow-Origin","http://120.24.24.239:8088");
//// response.setHeader("Access-Control-Allow-Origin",request.getHeader("Origin"));
// response.setHeader("Access-Control-Allow-Methods", "*");
// response.setHeader("Access-Control-Allow-Credentials", "true");
// response.setHeader("Access-Control-Allow-Headers", "*");
//
// System.out.print("request.Origin>"+request.getHeader("Origin"));
// //option预检查,直接通过请求
// if ("OPTIONS".equals(request.getMethod())){
// return true;
// }
/*
* Enumeration<String> names = request.getHeaderNames();
* while(names.hasMoreElements()) { String name = (String)names.nextElement();
...
...
src/main/java/cn/timer/api/config/interceptor/WebSecurityConfig.java
View file @
8f375736
...
...
@@ -80,13 +80,18 @@ public class WebSecurityConfig implements WebMvcConfigurer {
argumentResolvers
.
add
(
userMethodArgumentResolver
);
}
// @Override
// public void addCorsMappings(CorsRegistry registry) {
// registry.addMapping("/**")
// .allowedOrigins("*")
// .allowCredentials(true)
// .allowedMethods("GET", "POST", "DELETE", "PUT","PATCH")
// .maxAge(3600);
// @Override
// public void addCorsMappings(CorsRegistry registry) {
//// System.out.println("我是MyWebConfig跨域");
// //设置允许跨域的路径
// registry.addMapping("/**")
// //设置允许跨域请求的域名
// .allowedOrigins("*")
// //是否允许证书 不再默认开启
// .allowCredentials(true)
// //设置允许的方法
// .allowedMethods("*")
// //跨域允许时间
// .maxAge(3600);
// }
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment