|
@@ -64,7 +64,7 @@ public class WechatFilter implements Filter {
|
|
|
public void forword(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws Exception {
|
|
|
// 如果不是扫描二维码,那么获取后转发微信服务器,完成授权。
|
|
|
String query = req.getQueryString();
|
|
|
- String urlstr = req.getRequestURI().toString().replace(req.getContextPath(), "");
|
|
|
+ String urlstr = req.getRequestURI().replace(req.getContextPath(), "");
|
|
|
if (query != null) {
|
|
|
urlstr = urlstr + "?" + query;
|
|
|
}
|
|
@@ -73,8 +73,8 @@ public class WechatFilter implements Filter {
|
|
|
// 判断请求,如果是来自Ajax,那么直接返回302跳转会导致前端报错,所以返回JSON格式数据,状态为200
|
|
|
String requestedWith = req.getHeader("x-requested-with");
|
|
|
String accept = req.getHeader("accept");
|
|
|
- if ((requestedWith != null && StringUtils.isNotEmpty(requestedWith) && requestedWith.indexOf("XMLHttpRequest") != -1)
|
|
|
- || (accept != null && StringUtils.isNotEmpty(accept) && accept.indexOf("json") != -1)) {
|
|
|
+ if ((StringUtils.isNotEmpty(requestedWith) && requestedWith.contains("XMLHttpRequest"))
|
|
|
+ || (accept != null && StringUtils.isNotEmpty(accept) && accept.contains("json"))) {
|
|
|
// 客户端需要的是json数据
|
|
|
String redirectURL = req.getHeader("Referer");
|
|
|
resp.getWriter().write("{\"isRedirect\":true, \"redirectURL\":\"" + WechatUtils.getOpenIdFunction(redirectURL) + "\"}");
|