mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 20:50:14 +08:00
社交账号登录 &图片上传
This commit is contained in:
@@ -231,8 +231,8 @@ public class InitializeContext extends HttpServlet {
|
||||
*/
|
||||
public void showLicense() {
|
||||
_logger.info("-----------------------------------------------------------");
|
||||
_logger.info("+ MaxKey ");
|
||||
_logger.info("+ Single Sign On ( SSO ) ");
|
||||
_logger.info("+ MaxKey Community Edition ");
|
||||
_logger.info("+ Single Sign On ( SSO ) ");
|
||||
_logger.info("+ Version {}",
|
||||
WebContext.properties.getProperty("application.formatted-version"));
|
||||
_logger.info("+");
|
||||
|
||||
@@ -179,9 +179,9 @@ public final class WebContext {
|
||||
*
|
||||
* @return String HttpContextPath
|
||||
*/
|
||||
public static String getHttpContextPath() {
|
||||
public static String getHttpContextPath(boolean isContextPath) {
|
||||
HttpServletRequest httpServletRequest = WebContext.getRequest();
|
||||
return getHttpContextPath(httpServletRequest);
|
||||
return getHttpContextPath(httpServletRequest,isContextPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,32 +190,44 @@ public final class WebContext {
|
||||
* @return String eg:http://192.168.1.20:9080/webcontext or
|
||||
* http://www.website.com/webcontext
|
||||
*/
|
||||
public static String getHttpContextPath(HttpServletRequest httpServletRequest) {
|
||||
public static String getHttpContextPath(HttpServletRequest request,boolean isContextPath) {
|
||||
ApplicationConfig applicationConfig =
|
||||
WebContext.getBean("applicationConfig",ApplicationConfig.class);
|
||||
|
||||
_logger.trace("Config ServerPrefix " + applicationConfig.getServerPrefix());
|
||||
_logger.trace("Config DomainName " + applicationConfig.getDomainName());
|
||||
_logger.trace("ServerName " + httpServletRequest.getServerName());
|
||||
_logger.trace("ServerName " + request.getServerName());
|
||||
|
||||
String httpContextPath ="";
|
||||
if (httpServletRequest.getServerName().matches(ipAddressRegex)
|
||||
||httpServletRequest.getServerName().equalsIgnoreCase("localhost")) {
|
||||
httpContextPath = httpServletRequest.getScheme().toLowerCase()
|
||||
+ "://"+httpServletRequest.getServerName();
|
||||
StringBuilder url = new StringBuilder();
|
||||
if (request.getServerName().matches(ipAddressRegex)
|
||||
||request.getServerName().equalsIgnoreCase("localhost")) {
|
||||
url.append(request.getScheme().toLowerCase())
|
||||
.append("://").append(request.getServerName())
|
||||
.append(request.getServerPort());
|
||||
}else {
|
||||
httpContextPath = applicationConfig.getServerName() ;
|
||||
String scheme = request.getScheme().toLowerCase();
|
||||
String serverName = request.getServerName();
|
||||
int serverPort = request.getServerPort();
|
||||
|
||||
url.append(scheme).append("://").append(serverName);
|
||||
// Only add port if not default
|
||||
if ("http".equals(scheme)) {
|
||||
if (serverPort != 80) {
|
||||
url.append(":").append(serverPort);
|
||||
}
|
||||
}
|
||||
else if ("https".equals(scheme)) {
|
||||
if (serverPort != 443) {
|
||||
url.append(":").append(serverPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int port = httpServletRequest.getServerPort();
|
||||
if(!(port==80 || port==443)){
|
||||
httpContextPath += ":"+port;
|
||||
if(isContextPath) {
|
||||
url.append(request.getContextPath());
|
||||
}
|
||||
|
||||
httpContextPath += httpServletRequest.getContextPath() + "";
|
||||
|
||||
_logger.trace("httpContextPath " + httpContextPath);
|
||||
return httpContextPath;
|
||||
_logger.trace("httpContextPath {}" , url);
|
||||
return url.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class BasePathTagDirective implements TemplateDirectiveModel {
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
|
||||
env.getOut().append(WebContext.getHttpContextPath(request));
|
||||
env.getOut().append(WebContext.getHttpContextPath(request,true));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user