增加ctxPath参数,当映射根路径不同的时候使用
This commit is contained in:
@@ -63,7 +63,8 @@ public class PermissionsFilter extends org.apache.shiro.web.filter.authz.Permiss
|
||||
// AJAX不支持Redirect改用Forward
|
||||
String loginUrl = Global.getProperty("shiro.defaultPath");
|
||||
HttpServletRequest req = ((HttpServletRequest) request);
|
||||
if (StringUtils.equals(req.getContextPath()+loginUrl, req.getRequestURI())){
|
||||
|
||||
if (StringUtils.equals(Global.getCtxPath() + loginUrl, req.getRequestURI())){
|
||||
loginUrl = Global.getProperty("shiro.loginUrl");
|
||||
}
|
||||
if (ServletUtils.isAjaxRequest(req)) {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.jeesite.common.ueditor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.ueditor.define.ActionMap;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
@@ -12,6 +8,9 @@ import com.jeesite.common.ueditor.define.State;
|
||||
import com.jeesite.common.ueditor.hunter.FileManager;
|
||||
import com.jeesite.common.ueditor.hunter.ImageHunter;
|
||||
import com.jeesite.common.ueditor.upload.Uploader;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ActionEnter {
|
||||
|
||||
@@ -32,7 +31,7 @@ public class ActionEnter {
|
||||
this.request = request;
|
||||
this.rootPath = rootPath;
|
||||
this.actionType = actionType;
|
||||
this.contextPath = request.getContextPath();
|
||||
this.contextPath = Global.getCtxPath();
|
||||
this.configManager = ConfigManager.getInstance(this.rootPath, this.contextPath, request.getRequestURI());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package com.jeesite.common.ueditor.hunter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.ueditor.PathFormat;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
import com.jeesite.common.ueditor.define.BaseState;
|
||||
import com.jeesite.common.ueditor.define.MultiState;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileManager {
|
||||
|
||||
@@ -70,7 +69,7 @@ public class FileManager {
|
||||
if (index >= 0) {
|
||||
url = url.substring(index + USERFILES_BASE_URL.length());
|
||||
}
|
||||
fileState.putInfo("url", request.getContextPath() + USERFILES_BASE_URL + url);
|
||||
fileState.putInfo("url", Global.getCtxPath() + USERFILES_BASE_URL + url);
|
||||
state.addState(fileState);
|
||||
}
|
||||
return state;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -80,7 +81,7 @@ public class ImageHunter {
|
||||
String physicalPath = this.rootPath + savePath;
|
||||
State state = StorageManager.saveFileByInputStream(connection.getInputStream(), physicalPath);
|
||||
if (state.isSuccess()) {
|
||||
state.putInfo("url", request.getContextPath() + PathFormat.format(savePath));
|
||||
state.putInfo("url", Global.getCtxPath() + PathFormat.format(savePath));
|
||||
state.putInfo("source", urlStr);
|
||||
}
|
||||
return state;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.jeesite.common.ueditor.upload;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.ueditor.PathFormat;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
import com.jeesite.common.ueditor.define.BaseState;
|
||||
import com.jeesite.common.ueditor.define.FileType;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class Base64Uploader {
|
||||
|
||||
@@ -27,8 +26,8 @@ public final class Base64Uploader {
|
||||
String physicalPath = (String) conf.get("rootPath") + savePath;
|
||||
State storageState = StorageManager.saveBinaryFile(data, physicalPath);
|
||||
if (storageState.isSuccess()) {
|
||||
String ctx = request.getContextPath(); // ThinkGem 修正上传图片后返回无contextpath问题
|
||||
storageState.putInfo("url", ctx + PathFormat.format(savePath));
|
||||
String ctxPath = Global.getCtxPath(); // ThinkGem 修正上传图片后返回无contextpath问题
|
||||
storageState.putInfo("url", ctxPath + PathFormat.format(savePath));
|
||||
storageState.putInfo("type", suffix);
|
||||
storageState.putInfo("original", "");
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jeesite.common.ueditor.upload;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.image.ImageUtils;
|
||||
import com.jeesite.common.io.FileUtils;
|
||||
import com.jeesite.common.media.VideoUtils;
|
||||
@@ -73,7 +74,7 @@ public class BinaryUploader {
|
||||
|
||||
if (storageState != null && storageState.isSuccess()) {
|
||||
int actionCode = ((Integer) conf.get("actionCode")).intValue();
|
||||
String ctx = request.getContextPath(); // ThinkGem 修正上传图片后返回无contextpath问题
|
||||
String ctxPath = Global.getCtxPath(); // ThinkGem 修正上传图片后返回无contextpath问题
|
||||
|
||||
// 上传图片后,进行图片压缩
|
||||
if (actionCode == ActionMap.UPLOAD_IMAGE) {
|
||||
@@ -105,7 +106,7 @@ public class BinaryUploader {
|
||||
};
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
storageState.putInfo("url", ctx + PathFormat.format(savePath) + "." + v.getOutputFileExtension());
|
||||
storageState.putInfo("url", ctxPath + PathFormat.format(savePath) + "." + v.getOutputFileExtension());
|
||||
storageState.putInfo("type", "." + v.getOutputFileExtension());
|
||||
storageState.putInfo("original", originFileName + "." + v.getInputFileExtension());
|
||||
|
||||
@@ -115,7 +116,7 @@ public class BinaryUploader {
|
||||
return storageState;
|
||||
}
|
||||
}
|
||||
storageState.putInfo("url", ctx + PathFormat.format(savePath));
|
||||
storageState.putInfo("url", ctxPath + PathFormat.format(savePath));
|
||||
storageState.putInfo("type", suffix);
|
||||
storageState.putInfo("original", originFileName + suffix);
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
import com.jeesite.common.ueditor.define.BaseState;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
import com.jeesite.common.web.http.ServletUtils;
|
||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -204,8 +202,7 @@ public class StorageManager {
|
||||
String url = FileUploadUtils.ossFileUpload(file, StringUtils.substringAfter(
|
||||
FileUtils.path(file.getAbsolutePath()), Global.USERFILES_BASE_URL));
|
||||
if (!StringUtils.contains(url, "://")) {
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
url = FileUtils.path((request != null ? request.getContextPath() : StringUtils.EMPTY) + url);
|
||||
url = FileUtils.path(Global.getCtxPath() + url);
|
||||
}
|
||||
storageState.putInfo("url", url);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class UserfilesController extends BaseController {
|
||||
String uid = request.getParameter("uid");
|
||||
if (StringUtils.isNotBlank(url) && StringUtils.isNotBlank(uid)){
|
||||
fileUrl = url; //EncodeUtils.decodeUrl(url); 不用解码,否则腾讯云存储的时候预览不能显示
|
||||
fileUri = request.getContextPath() + Global.getAdminPath() + "/file/download/" + uid;
|
||||
fileUri = Global.getCtxPath() + Global.getAdminPath() + "/file/download/" + uid;
|
||||
filePath = fileName;
|
||||
} else if (StringUtils.isNotBlank(fileName)){
|
||||
fileUri += "?fileName=" + EncodeUtils.encodeUrl(fileName);
|
||||
|
||||
@@ -117,8 +117,7 @@ public class LogUtils {
|
||||
Object targetData = request.getAttribute(WebDataBinder.class.getName()+".TARGET");
|
||||
|
||||
// 异步保存日志
|
||||
logThreadPool.submit(new SaveLogThread(log, handler, request.getContextPath(),
|
||||
throwable, sourceData, targetData));
|
||||
logThreadPool.submit(new SaveLogThread(log, handler, Global.getCtxPath(), throwable, sourceData, targetData));
|
||||
}
|
||||
/**
|
||||
* 保存日志线程
|
||||
|
||||
@@ -230,10 +230,11 @@ public class LoginController extends BaseController{
|
||||
successUrl = (String)request.getAttribute("__url");
|
||||
}
|
||||
if (StringUtils.contains(successUrl, "://")){
|
||||
String ctxPath = Global.getCtxPath();
|
||||
String domain = ServletUtils.getRequestDomain(successUrl);
|
||||
successUrl = StringUtils.substring(successUrl, domain.length());
|
||||
if (StringUtils.startsWith(successUrl, request.getContextPath())) {
|
||||
successUrl = StringUtils.substringAfter(successUrl, request.getContextPath());
|
||||
if (StringUtils.startsWith(successUrl, ctxPath)) {
|
||||
successUrl = StringUtils.substringAfter(successUrl, ctxPath);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(successUrl)){
|
||||
@@ -251,7 +252,7 @@ public class LoginController extends BaseController{
|
||||
}
|
||||
model.addAttribute("sessionid", (String)session.getId());
|
||||
if (!StringUtils.contains(successUrl, "://")){
|
||||
successUrl = request.getContextPath() + successUrl;
|
||||
successUrl = Global.getCtxPath() + successUrl;
|
||||
}
|
||||
model.addAttribute("__url", successUrl); // 告诉浏览器登录后跳转的页面
|
||||
// 初始密码策略和密码修改策略验证(0:关闭;1:提醒用户;2:强制修改初始或旧密码)
|
||||
|
||||
@@ -39,9 +39,9 @@ for (var menu in p.menuList![]){
|
||||
if (@StringUtils.startsWith(href, "///")){
|
||||
href = @StringUtils.substring(href, 2);
|
||||
} else if (@StringUtils.startsWith(href, "//")){
|
||||
href = @request.getContextPath() + @StringUtils.substring(href, 1);
|
||||
href = @Global.getCtxPath() + @StringUtils.substring(href, 1);
|
||||
} else if (@StringUtils.startsWith(href, "/")){
|
||||
href = @request.getContextPath() + @Global.getAdminPath() + href;
|
||||
href = @Global.getCtxPath() + @Global.getAdminPath() + href;
|
||||
}
|
||||
attrs = attrs + 'href="' + href + '"';
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user