This commit is contained in:
bwcx_jzy 2019-08-29 22:34:26 -05:00
parent abb1f0fa19
commit 4d96ab0c96
3 changed files with 5 additions and 15 deletions

View File

@ -5,8 +5,6 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
import cn.jiangzeyin.common.interceptor.BaseInterceptor;
import io.jpom.system.JpomRuntimeException;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.method.HandlerMethod;
@ -36,18 +34,9 @@ public abstract class BaseJpomInterceptor extends BaseInterceptor {
return Convert.toBool(request.getAttribute("Page_Req"), true);
}
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url) throws IOException {
String proto = ServletUtil.getHeaderIgnoreCase(request, "X-Forwarded-Proto");
if (proto == null) {
response.sendRedirect(getHeaderProxyPath(request) + url);
} else {
String host = request.getHeader(HttpHeaders.HOST);
if (StrUtil.isEmpty(host)) {
throw new JpomRuntimeException("请配置host header");
}
String toUrl = StrUtil.format("{}://{}{}{}", proto, host, getHeaderProxyPath(request), url);
response.sendRedirect(toUrl);
}
public void sendRedirects(HttpServletRequest request, HttpServletResponse response, String url) throws IOException {
url = getHeaderProxyPath(request) + url;
BaseInterceptor.sendRedirect(request, response, url);
}
/**

View File

@ -127,7 +127,7 @@ public class LoginInterceptor extends BaseJpomInterceptor {
if (header != null) {
url += "&r=" + header;
}
super.sendRedirect(request, response, url);
super.sendRedirects(request, response, url);
return;
}
ServletUtil.write(response, JsonMessage.getString(800, "登录信息已失效,重新登录"), MediaType.APPLICATION_JSON_UTF8_VALUE);

View File

@ -50,6 +50,7 @@
</button>
</div>
</form>
</body>
<script type="text/javascript"
th:src="@{${session.jpomProxyPath}+'/static/js/auto-line-number.js?v='+${session.staticCacheTime}}"></script>