wangbing 5 years ago
parent 0e0c3d3352
commit b3042fda16

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

@ -16,21 +16,22 @@ public class Index extends Screen {
@Override @Override
public void exec(Model model, HttpServletRequest request, HttpServletResponse response) { public void exec(Model model, HttpServletRequest request, HttpServletResponse response) {
String path = request.getParameter("path"); String path = request.getParameter("path");
String filePath = null;
if (path == null) { if (path == null) {
path = root; filePath = root;
} else { } else {
path = root + "/" + path; filePath = root + "/" + path;
} }
System.out.println(path); System.out.println(path);
File rootFile = new File(path); File rootFile = new File(filePath);
if (!rootFile.exists()) { if (!rootFile.exists()) {
rootFile.mkdirs(); rootFile.mkdirs();
} }
File[] files = rootFile.listFiles(); File[] files = rootFile.listFiles();
model.addAttribute("files", files); model.addAttribute("files", files);
model.addAttribute("path", new HtmlHepler().getPath(rootFile)); model.addAttribute("path", path);
model.addAttribute("html", new HtmlHepler()); model.addAttribute("html", new HtmlHepler());
} }
@ -54,7 +55,7 @@ public class Index extends Screen {
for (File f : file.listFiles()) { for (File f : file.listFiles()) {
sb.append("<li>"); sb.append("<li>");
if (f.isDirectory()) { 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(f.getName());
sb.append("</a>"); sb.append("</a>");
sb.append(getHtml(f)); 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> <div class="file">
<form action="upload" method="post" enctype="multipart/form-data"> <form action="upload" method="post" enctype="multipart/form-data">
<input type="file" name="file"> <input type="file" name="file">
<input type="hidden" name="path" value="${path}"> <input type="hidden" name="path" value="${path}">
@ -11,7 +11,7 @@
<#list files as item> <#list files as item>
<li> <li>
<#if item.isDirectory()> <#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> <#else>
<a target="_blank" href='download?file=${html.getPath(item)}'>${item.name}</a> <a target="_blank" href='download?file=${html.getPath(item)}'>${item.name}</a>
</#if> </#if>
@ -77,6 +77,11 @@
pointer-events: none pointer-events: none
} }
.file {
padding-bottom: 10px;
border-bottom: 3px solid #00a2e2;
}
.dir { .dir {
} }

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

Powered by TurnKey Linux.