|
@@ -0,0 +1,39 @@
|
|
|
|
+/*
|
|
|
|
+ * *************************************************
|
|
|
|
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
|
|
|
|
+ * Created by Deason on 2018-08-21 17:51:26.
|
|
|
|
+ * *************************************************
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+package cn.com.qmth.examcloud.app.core.config;
|
|
|
|
+
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+import org.springframework.web.servlet.View;
|
|
|
|
+import org.springframework.web.servlet.ViewResolver;
|
|
|
|
+import org.springframework.web.servlet.view.RedirectView;
|
|
|
|
+
|
|
|
|
+import java.util.Locale;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Resolver HTTP STATUS 301
|
|
|
|
+ *
|
|
|
|
+ * @author: fengdesheng
|
|
|
|
+ * @since: 2018/8/21
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+public class RedirectViewResolver implements ViewResolver {
|
|
|
|
+ public static final String REDIRECT_PERMANENT_PREFIX = "redirectPermanent:";
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public View resolveViewName(String viewName, Locale locale) throws Exception {
|
|
|
|
+ if (viewName.startsWith(REDIRECT_PERMANENT_PREFIX)) {
|
|
|
|
+ String redirectUrl = viewName.substring(REDIRECT_PERMANENT_PREFIX.length());
|
|
|
|
+ RedirectView view = new RedirectView(redirectUrl);
|
|
|
|
+ view.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
|
|
|
|
+ return view;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|