diff --git a/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/chapter19/dao/UrlFilterDaoImpl.java b/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/chapter19/dao/UrlFilterDaoImpl.java index 79589ff0..e68f0981 100644 --- a/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/chapter19/dao/UrlFilterDaoImpl.java +++ b/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/chapter19/dao/UrlFilterDaoImpl.java @@ -25,7 +25,7 @@ public class UrlFilterDaoImpl implements UrlFilterDao { private JdbcTemplate jdbcTemplate; public UrlFilter createUrlFilter(final UrlFilter urlFilter) { - final String sql = "insert into sys_url_filter(name, url, roles, permissions) values(?,?,?,?,?)"; + final String sql = "insert into sys_url_filter(name, url, roles, permissions) values(?,?,?,?)"; GeneratedKeyHolder keyHolder = new GeneratedKeyHolder(); jdbcTemplate.update(new PreparedStatementCreator() { diff --git a/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/chapter19/entity/UrlFilter.java b/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/chapter19/entity/UrlFilter.java index 9a5ea00b..0547b6c8 100644 --- a/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/chapter19/entity/UrlFilter.java +++ b/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/chapter19/entity/UrlFilter.java @@ -9,10 +9,10 @@ */ public class UrlFilter implements Serializable { private Long id; - private String name; - private String url; - private String roles; - private String permissions; + private String name; //url名称/描述 + private String url; //地址 + private String roles; //所需要的角色,可省略 + private String permissions; //所需要的权限,可省略 public Long getId() { return id; diff --git a/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/spring/CustomDefaultFilterChainManager.java b/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/spring/CustomDefaultFilterChainManager.java index a19bfcff..2bf7e163 100644 --- a/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/spring/CustomDefaultFilterChainManager.java +++ b/shiro-example-chapter19/src/main/java/com/github/zhangkaitao/shiro/spring/CustomDefaultFilterChainManager.java @@ -35,7 +35,7 @@ public class CustomDefaultFilterChainManager extends DefaultFilterChainManager { public CustomDefaultFilterChainManager() { setFilters(new LinkedHashMap()); setFilterChains(new LinkedHashMap()); - addDefaultFilters(true); + addDefaultFilters(false); } public Map getFilterChainDefinitionMap() { @@ -47,7 +47,9 @@ public void setFilterChainDefinitionMap(Map filterChainDefinitio } public void setCustomFilters(Map customFilters) { - getFilters().putAll(customFilters); + for(Map.Entry entry : customFilters.entrySet()) { + addFilter(entry.getKey(), entry.getValue(), false); + } } @@ -90,12 +92,6 @@ public void setUnauthorizedUrl(String unauthorizedUrl) { @PostConstruct public void init() { - Map defaultFilters = getFilters(); - //apply global settings if necessary: - for (Filter filter : defaultFilters.values()) { - applyGlobalPropertiesIfNecessary(filter); - } - //Apply the acquired and/or configured filters: Map filters = getFilters(); if (!CollectionUtils.isEmpty(filters)) { @@ -106,9 +102,6 @@ public void init() { if (filter instanceof Nameable) { ((Nameable) filter).setName(name); } - //'init' argument is false, since Spring-configured filters should be initialized - //in Spring (i.e. 'init-method=blah') or implement InitializingBean: - addFilter(name, filter, false); } }