This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strconv" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
func main() { | |
port := ":8000" | |
log.Printf("Serving at: http://localhost%s\n", port) |