增加ctxPath参数,当映射根路径不同的时候使用
This commit is contained in:
@@ -4,23 +4,21 @@
|
||||
*/
|
||||
package com.jeesite.common.shiro.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.web.util.WebUtils;
|
||||
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.web.http.ServletUtils;
|
||||
import com.jeesite.common.web.http.wrapper.GetHttpServletRequestWrapper;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.web.util.WebUtils;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 权限字符串过滤器
|
||||
@@ -65,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 javax.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 javax.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 javax.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 org.apache.commons.io.FileUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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;
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package com.jeesite.common.ueditor.hunter;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.ueditor.PathFormat;
|
||||
import com.jeesite.common.ueditor.define.*;
|
||||
import com.jeesite.common.ueditor.upload.StorageManager;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
@@ -8,18 +15,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
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.MIMEType;
|
||||
import com.jeesite.common.ueditor.define.MultiState;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
import com.jeesite.common.ueditor.upload.StorageManager;
|
||||
|
||||
/**
|
||||
* 图片抓取器
|
||||
*
|
||||
@@ -80,7 +75,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 javax.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 org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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,10 +8,8 @@ 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 javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
|
||||
public class StorageManager {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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:强制修改初始或旧密码)
|
||||
|
||||
Reference in New Issue
Block a user