作者 朱兆平

处理匿名者访问方法转json对象异常问题

@@ -172,20 +172,27 @@ public class WrapperResponseGlobalFilter implements GlobalFilter, Ordered { @@ -172,20 +172,27 @@ public class WrapperResponseGlobalFilter implements GlobalFilter, Ordered {
172 String redisKey = "ROLE_anonymous_routers"; 172 String redisKey = "ROLE_anonymous_routers";
173 String json = stringRedisTemplate.opsForValue().get(redisKey); 173 String json = stringRedisTemplate.opsForValue().get(redisKey);
174 if(json!=null && !json.isEmpty()){ 174 if(json!=null && !json.isEmpty()){
175 - JSONObject jsonObject = JSONObject.parseObject(json);  
176 - List<ROLE> roleList = JSONObject.toJavaObject(jsonObject,List.class);  
177 - if(roleList!=null && !roleList.isEmpty()){  
178 - for (ROLE role: roleList){  
179 - List<PERMISSION> permissionList= role.getPermissions();  
180 - if(permissionList!=null && !permissionList.isEmpty()){  
181 - for (PERMISSION permission : permissionList) {  
182 - if (pathMatcher.match(permission.getUrl(), request.getPath().toString())) {  
183 - return true;  
184 - }  
185 - }  
186 - } 175 + try{
  176 + JSONObject jsonObject = JSONObject.parseObject(json);
  177 + List<ROLE> roleList = JSONObject.toJavaObject(jsonObject,List.class);
  178 + if(roleList!=null && !roleList.isEmpty()){
  179 + for (ROLE role: roleList){
  180 + List<PERMISSION> permissionList= role.getPermissions();
  181 + if(permissionList!=null && !permissionList.isEmpty()){
  182 + for (PERMISSION permission : permissionList) {
  183 + if (pathMatcher.match(permission.getUrl(), request.getPath().toString())) {
  184 + return true;
  185 + }
  186 + }
  187 + }
  188 + }
187 } 189 }
  190 + }catch (Exception e){
  191 + e.printStackTrace();
  192 + return false;
188 } 193 }
  194 +
  195 +
189 } 196 }
190 return false; 197 return false;
191 } 198 }
  1 +${AnsiColor.YELLOW}
  2 + ##################*CETC-TIANBO*#########################
  3 +
  4 + .::::.
  5 + .::::::::.
  6 + :::::::::::
  7 + ..:::::::::::'
  8 + '::::::::::::'
  9 + .::::::::::
  10 + '::::::::::::::..
  11 + ..::::::::::::.
  12 + ``::::::::::::::::
  13 + ::::``:::::::::' .:::.
  14 + ::::' ':::::' .::::::::.
  15 + .::::' :::: .:::::::'::::.
  16 + .:::' ::::: .:::::::::' ':::::.
  17 + .::' :::::.:::::::::' ':::::.
  18 + .::' ::::::::::::::' ``::::.
  19 + ...::: ::::::::::::' ``::.
  20 + ```` ':. ':::::::::' ::::..
  21 + '.:::::' ':'````..
  22 + #########################################################
  23 +
  24 +
  25 +
  26 +
  27 +==================================================
  28 +Application Info:${application.title}
  29 +ver:${application.version}
  30 +Powered by:Spring Boot ${spring-boot.version}