解决静态路径问题

This commit is contained in:
gy b
2023-09-15 20:06:01 +08:00
parent 857ae6a0a1
commit 04d9172cce
2 changed files with 7 additions and 11 deletions
@@ -2,6 +2,7 @@ package com.ruoyi.common.enums;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@@ -9,28 +10,23 @@ import org.springframework.lang.Nullable;
* *
* @author ruoyi * @author ruoyi
*/ */
public enum HttpMethod public enum HttpMethod {
{
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE; GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
private static final Map<String, HttpMethod> mappings = new HashMap<>(16); private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
static static {
{ for (HttpMethod httpMethod : values()) {
for (HttpMethod httpMethod : values())
{
mappings.put(httpMethod.name(), httpMethod); mappings.put(httpMethod.name(), httpMethod);
} }
} }
@Nullable @Nullable
public static HttpMethod resolve(@Nullable String method) public static HttpMethod resolve(@Nullable String method) {
{
return (method != null ? mappings.get(method) : null); return (method != null ? mappings.get(method) : null);
} }
public boolean matches(String method) public boolean matches(String method) {
{
return (this == resolve(method)); return (this == resolve(method));
} }
} }
@@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage").permitAll() .antMatchers("/login", "/register", "/captchaImage","/home/**").permitAll()
// 静态资源,可匿名访问 // 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()