Skip to content

Instantly share code, notes, and snippets.

package main
import (
"bufio"
"fmt"
"os"
"strconv"
"time"
)
@windhc
windhc / SpringMvcFileDownload.java
Created March 30, 2018 06:23
spring mvc + ajax无刷新下载文件
@RequestMapping(value = "/download")
public ResponseEntity<byte[]> download(HttpServletRequest request,
@RequestParam("filename") String filename,
Model model) throws Exception {
//下载文件路径
String path = request.getServletContext().getRealPath("/images/");
File file = new File(path + File.separator + filename);
HttpHeaders headers = new HttpHeaders();
//下载显示的文件名,解决中文名称乱码问题
String downloadFielName = new String(filename.getBytes("UTF-8"), "iso-8859-1");
@windhc
windhc / fileServer.go
Last active February 7, 2018 14:13
go简单静态页面服务
package main
import (
"log"
"net/http"
)
func main() {
port := ":8000"
log.Printf("Serving at: http://localhost%s\n", port)