Commit 2bbf0109 authored by mhqpx's avatar mhqpx Committed by klboke

文件预览:移除needE参数

parent eb3d36e5
......@@ -27,10 +27,11 @@ public class DownloadUtils {
* @param type
* @return
*/
public ReturnResponse<String> downLoad(String urlAddress, String type, String fileName, String needEncode){
public ReturnResponse<String> downLoad(String urlAddress, String type, String fileName){
ReturnResponse<String> response = new ReturnResponse<>(0, "下载成功!!!", "");
URL url = null;
try {
urlAddress = replacePlusMark(urlAddress);
urlAddress = encodeUrlParam(urlAddress);
// 因为tomcat不能处理'+'号,所以讲'+'号替换成'%20%'
urlAddress = urlAddress.replaceAll("\\+", "%20");
......@@ -92,10 +93,13 @@ public class DownloadUtils {
* @return
*/
private String replacePlusMark(String urlAddress) {
if (urlAddress.contains("?")) {
String nonParamStr = urlAddress.substring(0,urlAddress.indexOf("?") + 1);
String paramStr = urlAddress.substring(nonParamStr.length());
return nonParamStr + paramStr.replace(" ", "+");
}
return urlAddress;
}
/**
* 对最有一个路径进行转码
......
......@@ -17,8 +17,8 @@ public class SimTextUtil {
@Autowired
DownloadUtils downloadUtils;
public ReturnResponse<String> readSimText(String url, String fileName, String needEncode){
ReturnResponse<String> response = downloadUtils.downLoad(url, "txt", fileName, needEncode);
public ReturnResponse<String> readSimText(String url, String fileName){
ReturnResponse<String> response = downloadUtils.downLoad(url, "txt", fileName);
return response;
}
}
......@@ -50,7 +50,7 @@ public class OnlinePreviewController {
* @return
*/
@RequestMapping(value = "onlinePreview",method = RequestMethod.GET)
public String onlinePreview(String url, String needEncode, Model model, HttpServletRequest req) throws UnsupportedEncodingException {
public String onlinePreview(String url, Model model, HttpServletRequest req) throws UnsupportedEncodingException {
// 路径转码
String decodedUrl = URLDecoder.decode(url, "utf-8");
String type = typeFromUrl(url);
......@@ -62,7 +62,7 @@ public class OnlinePreviewController {
model.addAttribute("imgurl", url);
return "picture";
} else if (type.equalsIgnoreCase("simText")){
ReturnResponse<String> response = simTextUtil.readSimText(decodedUrl, fileName, needEncode);
ReturnResponse<String> response = simTextUtil.readSimText(decodedUrl, fileName);
if (0 != response.getCode()) {
model.addAttribute("msg", response.getMsg());
return "fileNotSupported";
......@@ -76,7 +76,7 @@ public class OnlinePreviewController {
String fileTree = null;
// 判断文件名是否存在(redis缓存读取)
if (!StringUtils.hasText(fileUtils.getConvertedFile(fileName))) {
ReturnResponse<String> response = downloadUtils.downLoad(decodedUrl, suffix, fileName, needEncode);
ReturnResponse<String> response = downloadUtils.downLoad(decodedUrl, suffix, fileName);
if (0 != response.getCode()) {
model.addAttribute("msg", response.getMsg());
return "fileNotSupported";
......@@ -109,7 +109,7 @@ public class OnlinePreviewController {
if (!fileUtils.listConvertedFiles().containsKey(pdfName)) {
String filePath = fileDir + fileName;
if (!new File(filePath).exists()) {
ReturnResponse<String> response = downloadUtils.downLoad(decodedUrl, suffix, null, needEncode);
ReturnResponse<String> response = downloadUtils.downLoad(decodedUrl, suffix, null);
if (0 != response.getCode()) {
model.addAttribute("msg", response.getMsg());
return "fileNotSupported";
......
......@@ -69,8 +69,7 @@
fulls += ",resizable"; // 对于不支持screen属性的浏览器,可以手工进行最大化。 manually
}
window.open("onlinePreview?url="
+ encodeURIComponent("${baseUrl}" + treeNode.fileName)
+ "&needEncode=1", "_blank",fulls);
+ encodeURIComponent("${baseUrl}" + treeNode.fileName), "_blank",fulls);
}
}
}
......
......@@ -125,7 +125,7 @@
// 每个data添加一列用来操作
$(data).each(function (index, item) {
item.action = "<a class='btn btn-default' target='_blank' href='${baseUrl}onlinePreview?url="
+ encodeURIComponent('${baseUrl}' + item.fileName ) +"&needEncode=1'>预览</a>" +
+ encodeURIComponent('${baseUrl}' + item.fileName ) +"'>预览</a>" +
"<a class='btn btn-default' target='_blank' href='javascript:void(0);' onclick='deleteFile(\""+item.fileName+"\")'>删除</a>";
});
return data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment