修复:addTask异常

This commit is contained in:
陈精华
2020-04-14 11:17:07 +08:00
committed by kl
parent 2144b776b1
commit e0b1cd76ca
7 changed files with 26 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
package cn.keking.web.filter;
import cn.keking.config.ConfigConstants;
import org.springframework.web.context.request.RequestContextHolder;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
@@ -17,6 +18,18 @@ public class ChinesePathFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
}
private static String BASE_URL;
public static String getBaseUrl() {
String baseUrl;
try {
baseUrl = (String) RequestContextHolder.currentRequestAttributes().getAttribute("baseUrl",0);
} catch (Exception e) {
baseUrl = BASE_URL;
}
return baseUrl;
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
@@ -36,6 +49,7 @@ public class ChinesePathFilter implements Filter {
} else {
baseUrl = localBaseUrl;
}
BASE_URL = baseUrl;
request.setAttribute("baseUrl", baseUrl);
request.setAttribute("localBaseUrl", localBaseUrl);
chain.doFilter(request, response);