Pārlūkot izejas kodu

页面跳转修改

Signed-off-by: anderx <312518615@qq.com>
anderx 5 gadi atpakaļ
vecāks
revīzija
ccc55ce8fb

+ 3 - 25
src/main/java/com/kede/common/controller/WebpageController.java

@@ -47,9 +47,9 @@ public class WebpageController extends BaseController {
 		return modelview;
 	}
 	
-	@RequestMapping(value = "/admin/index", method = RequestMethod.GET)
+	@RequestMapping(value = "/admin/portal/index", method = RequestMethod.GET)
 	public ModelAndView adminHome(HttpServletRequest request, ModelAndView modelview) {
-		modelview.setViewName("/admin/index");
+		modelview.setViewName("/admin/portal/index");
 		return modelview;
 	}
 	
@@ -317,30 +317,8 @@ public class WebpageController extends BaseController {
 	
 	@RequestMapping(value = "/", method = RequestMethod.GET)
 	public ModelAndView home(HttpServletRequest request, ModelAndView modelview) {
-		RedirectView rv = new RedirectView();
-		modelview.setViewName("/portal/index");
-		rv.setExposeModelAttributes(false);
-		modelview.setView(rv);
-		return modelview;
+		return protalIndex(request, modelview);
 	}
-	/*@RequestMapping(value = "", method = RequestMethod.GET)
-	public ModelAndView shome(HttpServletRequest request, ModelAndView modelview) {
-		RedirectView rv = new RedirectView();
-		modelview.setViewName("/portal/index");
-		rv.setExposeModelAttributes(false);
-		modelview.setView(rv);
-		return modelview;
-	}*/
-	/*
-	@RequestMapping(value = "/null", method = RequestMethod.GET)
-	public ModelAndView isnull(HttpServletRequest request, ModelAndView modelview) {
-		RedirectView rv = new RedirectView();
-		modelview.setViewName("/portal/index");
-		rv.setExposeModelAttributes(false);
-		modelview.setView(rv);
-		return modelview;
-	}*/
-	
 	@SuppressWarnings("unchecked")
 	@RequestMapping(value = "/portal/index", method = RequestMethod.GET)
 	public ModelAndView protalIndex(HttpServletRequest request, ModelAndView modelview) {

+ 60 - 60
src/main/java/com/kede/core/shiro/filter/PermissionFilter.java

@@ -1,60 +1,60 @@
-package com.kede.core.shiro.filter;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.shiro.subject.Subject;
-import org.apache.shiro.util.StringUtils;
-import org.apache.shiro.web.filter.AccessControlFilter;
-import org.apache.shiro.web.util.WebUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.kede.common.bo.Error;
-import com.kede.common.bo.Result;
-import com.kede.common.constant.AFTConstants;
-import com.kede.common.utils.LoggerUtils;
-
-public class PermissionFilter extends AccessControlFilter {
-
-	@Autowired
-	private ShiroFilterUtils shiroFilterUtils;
-
-	@Override
-	protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
-			throws Exception {
-
-		// 先判断带参数的权限判断
-		Subject subject = getSubject(request, response);
-		HttpServletRequest httpRequest = ((HttpServletRequest) request);
-		String uri = httpRequest.getRequestURI();// 获取URI
-		String basePath = httpRequest.getContextPath();// 获取basePath
-		if (StringUtils.hasText(uri) && StringUtils.hasText(basePath) && uri.startsWith(basePath)) {
-			uri = uri.replaceAll("^\\" + basePath + "\\/+", "").replaceAll("\\.html$", "");
-		} else {
-			uri = uri.replaceAll("^\\/", "").replaceAll("\\.html$", "");
-		}
-		if (subject.isPermitted(uri) || subject.hasRole(AFTConstants.SUPERADMIN)) {
-			return Boolean.TRUE;
-		}
-		return Boolean.FALSE;
-	}
-
-	@Override
-	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
-		Subject subject = getSubject(request, response);
-		if (shiroFilterUtils.isAjax((HttpServletRequest) request)) {
-			LoggerUtils.debug(getClass(), "当前用户权限不够,并且是Ajax请求!");
-			shiroFilterUtils.out((HttpServletResponse) response, new Result().error(new Error("", "403", "当前用户权限不够!")));
-		} else if (null == subject.getPrincipal()) {
-			saveRequest(request);
-			//WebUtils.issueRedirect(request, response, getLoginUrl());
-			WebUtils.issueRedirect(request, response, "index");
-		} else {
-			WebUtils.toHttp(response).sendError(HttpServletResponse.SC_UNAUTHORIZED);
-		}
-		return Boolean.FALSE;
-	}
-
-}
+package com.kede.core.shiro.filter;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.util.StringUtils;
+import org.apache.shiro.web.filter.AccessControlFilter;
+import org.apache.shiro.web.util.WebUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.kede.common.bo.Error;
+import com.kede.common.bo.Result;
+import com.kede.common.constant.AFTConstants;
+import com.kede.common.utils.LoggerUtils;
+
+public class PermissionFilter extends AccessControlFilter {
+
+	@Autowired
+	private ShiroFilterUtils shiroFilterUtils;
+
+	@Override
+	protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
+			throws Exception {
+
+		// 先判断带参数的权限判断
+		Subject subject = getSubject(request, response);
+		HttpServletRequest httpRequest = ((HttpServletRequest) request);
+		String uri = httpRequest.getRequestURI();// 获取URI
+		String basePath = httpRequest.getContextPath();// 获取basePath
+		if (StringUtils.hasText(uri) && StringUtils.hasText(basePath) && uri.startsWith(basePath)) {
+			uri = uri.replaceAll("^\\" + basePath + "\\/+", "").replaceAll("\\.html$", "");
+		} else {
+			uri = uri.replaceAll("^\\/", "").replaceAll("\\.html$", "");
+		}
+		if (subject.isPermitted(uri) || subject.hasRole(AFTConstants.SUPERADMIN)) {
+			return Boolean.TRUE;
+		}
+		return Boolean.FALSE;
+	}
+
+	@Override
+	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
+		Subject subject = getSubject(request, response);
+		if (shiroFilterUtils.isAjax((HttpServletRequest) request)) {
+			LoggerUtils.debug(getClass(), "当前用户权限不够,并且是Ajax请求!");
+			shiroFilterUtils.out((HttpServletResponse) response, new Result().error(new Error("", "403", "当前用户权限不够!")));
+		} else if (null == subject.getPrincipal()) {
+			saveRequest(request);
+			//WebUtils.issueRedirect(request, response, getLoginUrl());
+			WebUtils.issueRedirect(request, response, "/portal/index");
+		} else {
+			WebUtils.toHttp(response).sendError(HttpServletResponse.SC_UNAUTHORIZED);
+		}
+		return Boolean.FALSE;
+	}
+
+}

+ 1 - 1
src/main/resources/shiro_base_auth.ini

@@ -1,6 +1,6 @@
 [base_auth]
 /=anon
-/index=anon
+/portal/index=anon
 /login=anon
 /user/login.html=anon
 /user/login=anon

+ 2 - 2
src/main/webapp/WEB-INF/views/admin/index.html

@@ -4,7 +4,7 @@
 <head th:replace="common::header(~{::title},~{::link})">
 	<title>管理中心首页</title>
 	<link th:href="${staticHost+'/dll/dll.css'}" rel="stylesheet">
-	<link th:href="${staticHost+'/admin/index.css'}" rel="stylesheet">
+	<link th:href="${staticHost+'/admin/portal/index.css'}" rel="stylesheet">
 </head>
 <body>
 	<div id="root"></div>
@@ -12,7 +12,7 @@
 	<div th:replace="common::footer(~{::script},'houtai')">
 		<script type="text/javascript" th:src="${staticHost+'/vendors.js'}"></script>
 		<script type="text/javascript" th:src="${staticHost+'/dll/dll.js'}"></script>
-		<script type="text/javascript" th:src="${staticHost+'/admin/index.js'}"></script>
+		<script type="text/javascript" th:src="${staticHost+'/admin/portal/index.js'}"></script>
 	</div>
 </body>
 </html>

+ 1 - 1
src/main/webapp/WEB-INF/views/common.html

@@ -453,7 +453,7 @@
         <div class="phone_footer">
 
             <div class="">
-                <a th:href="${basePath+'/poratal/index.html'}">
+                <a th:href="${basePath+'/poratal/portal/index.html'}">
                     <span class="iconfont icon-shouye"></span>
                     <p>首页</p>
                 </a>

+ 0 - 8
src/main/webapp/WEB-INF/web.xml

@@ -13,14 +13,6 @@
     <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
     <async-supported>true</async-supported>
   </filter>
-  
-<welcome-file-list>
-    <welcome-file>/protal/index.mtxl</welcome-file>
-</welcome-file-list>
-  <filter-mapping>
-    <filter-name>CorsFilter</filter-name>
-    <url-pattern>/*</url-pattern>
-  </filter-mapping>
   <filter>
     <filter-name>encodingFilter</filter-name>
     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>