src/main/java/com/whyc/config/ShiroConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/config/StaticResourceConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/controller/LoginController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/filter/KickedOutFilter.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/filter/LoginFilter.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/config/application.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/config/ShiroConfig.java
@@ -1,15 +1,11 @@ package com.whyc.config; import com.whyc.filter.KickedOutFilter; import com.whyc.filter.RolesOrAuthorizationFilter; import com.whyc.properties.PropertiesUtil; import com.whyc.realm.CustomRealm; import lombok.extern.log4j.Log4j; import lombok.extern.log4j.Log4j2; import org.apache.shiro.spring.LifecycleBeanPostProcessor; import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; import org.apache.shiro.spring.web.ShiroFilterFactoryBean; import org.apache.shiro.web.filter.authz.RolesAuthorizationFilter; import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.beans.factory.annotation.Autowired; @@ -95,8 +91,8 @@ shiroFilter.setFilters(filters()); shiroFilter.setSecurityManager(defaultWebSecurityManager()); shiroFilter.setFilterChainDefinitionMap(filterChainDefinition()); shiroFilter.setLoginUrl("/login.html"); //shiroFilter.setLoginUrl("/index.html#login"); shiroFilter.setLoginUrl("/login1.html"); //shiroFilter.setLoginUrl("/index1.html#login"); shiroFilter.setUnauthorizedUrl("/login/unauthorized"); return shiroFilter; } src/main/java/com/whyc/config/StaticResourceConfig.java
@@ -17,9 +17,16 @@ //这个是可行的,解析的时候path为*.html,校验路径admin下是否存在 //registry.addResourceHandler("admin/*.html").addResourceLocations("classpath:/META-INF/resources/admin/"); registry.addResourceHandler("/map/*").addResourceLocations("classpath:/META-INF/resources/map/"); //index.html静态 registry.addResourceHandler("/index.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/css/**").addResourceLocations("classpath:/META-INF/resources/css/"); registry.addResourceHandler("/js/**").addResourceLocations("classpath:/META-INF/resources/js/"); registry.addResourceHandler("/img/**").addResourceLocations("classpath:/META-INF/resources/img/"); registry.addResourceHandler("/fonts/**").addResourceLocations("classpath:/META-INF/resources/fonts/"); registry.addResourceHandler("/mapJson/**").addResourceLocations("classpath:/META-INF/resources/mapJson/"); registry.addResourceHandler("/theme/**").addResourceLocations("classpath:/META-INF/resources/theme/"); //registry.addResourceHandler("/login.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("*.html").addResourceLocations("classpath:/META-INF/resources/"); //doc.html静态 registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); registry.addResourceHandler("/service-worker.js").addResourceLocations("classpath:/META-INF/resources/"); //registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/META-INF/resources/"); src/main/java/com/whyc/controller/LoginController.java
@@ -40,11 +40,11 @@ @GetMapping("/") @ApiIgnore public ModelAndView toLoginHtml(HttpServletRequest request, HttpServletResponse response,ModelAndView view) throws ServletException, IOException { //request.getRequestDispatcher("login.html").forward(request,response); //request.getRequestDispatcher("login1.html").forward(request,response); System.out.println("转发啦..."); //response.setContentType("text/html;charset=utf-8"); //response.sendRedirect("http://localhost:8090/login.html"); //response.sendRedirect("/login.html"); //response.sendRedirect("/login1.html"); view.setViewName("login"); return view; }*/ src/main/java/com/whyc/filter/KickedOutFilter.java
@@ -27,7 +27,7 @@ //如果当前Session所对应的SessionId与全局中用户对应的SessionId不一致,则清除当前Session session.invalidate(); response.setContentType("text/html;charset=utf-8"); response.getWriter().write("<script language='javascript' type='text/javascript'>alert('账号已经在其他地方登录,请重新登录');self.location='login.html'</script> "); response.getWriter().write("<script language='javascript' type='text/javascript'>alert('账号已经在其他地方登录,请重新登录');self.location='login1.html'</script> "); return; } } src/main/java/com/whyc/filter/LoginFilter.java
@@ -47,7 +47,7 @@ // chain.doFilter(req, resp); // }else{ // PrintWriter out=resp.getWriter(); // out.print("<script charset='UTF-8'>window.location.href='index.html'</script>"); // out.print("<script charset='UTF-8'>window.location.href='index1.html'</script>"); // } // } // src/main/resources/config/application.yml
@@ -1,9 +1,8 @@ #服务端口号 server: port: 8090 # servlet: # context-path: /motor servlet: context-path: /screen #数据库 spring: datasource: