wangbing 5 years ago
parent 0e0c3d3352
commit b3042fda16

@ -137,7 +137,6 @@ public class GlobalController implements ErrorController {
}
@RequestMapping("/upload")
@ResponseBody
public String upload(HttpServletRequest request) {
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
MultipartFile target = multipartHttpServletRequest.getFile("file");
@ -164,7 +163,7 @@ public class GlobalController implements ErrorController {
e.printStackTrace();
}
return "";
return "screen/success";
}
@Value("${file.root.path}")

@ -16,21 +16,22 @@ public class Index extends Screen {
@Override
public void exec(Model model, HttpServletRequest request, HttpServletResponse response) {
String path = request.getParameter("path");
String filePath = null;
if (path == null) {
path = root;
filePath = root;
} else {
path = root + "/" + path;
filePath = root + "/" + path;
}
System.out.println(path);
File rootFile = new File(path);
File rootFile = new File(filePath);
if (!rootFile.exists()) {
rootFile.mkdirs();
}
File[] files = rootFile.listFiles();
model.addAttribute("files", files);
model.addAttribute("path", new HtmlHepler().getPath(rootFile));
model.addAttribute("path", path);
model.addAttribute("html", new HtmlHepler());
}
@ -54,7 +55,7 @@ public class Index extends Screen {
for (File f : file.listFiles()) {
sb.append("<li>");
if (f.isDirectory()) {
sb.append("<a class='dir' href='?path=" + getPath(f) + "'>");
sb.append("<a class='dir' href='?path=" + getPath(f) + "/'>");
sb.append(f.getName());
sb.append("</a>");
sb.append(getHtml(f));

@ -1,19 +0,0 @@
<div id="app" v-cloak>
</div>
<style>
</style>
<script>
var app = new Vue({
el: "#app",
data: {},
methods: {},
filters: {},
created: function () {
},
mounted: function () {
},
watch: {}
})
</script>

@ -1,5 +1,5 @@
<div>
<div>
<div class="file">
<form action="upload" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="hidden" name="path" value="${path}">
@ -11,7 +11,7 @@
<#list files as item>
<li>
<#if item.isDirectory()>
<a href="?path=${html.getPath(item)}" class="dir">${item.name}</a>
<a href="?path=${html.getPath(item)}/" class="dir">${item.name}</a>
<#else>
<a target="_blank" href='download?file=${html.getPath(item)}'>${item.name}</a>
</#if>
@ -77,6 +77,11 @@
pointer-events: none
}
.file {
padding-bottom: 10px;
border-bottom: 3px solid #00a2e2;
}
.dir {
}

@ -0,0 +1,3 @@
<div id="app">
上传成功!<a href="javascript:window.history.back(-1); ">返回</a>
</div>
Loading…
Cancel
Save

Powered by TurnKey Linux.