Commit f49b8c64 by zhongmh

解决中文乱码问题

parent 73c8bba3
......@@ -11,12 +11,14 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -32,9 +34,8 @@ public class IndexController {
@Autowired
private SystemFile systemFile;
@GetMapping({"index.html", "/"})
@ResponseBody
public String index() throws IOException {
@RequestMapping(value = {"index.html", "/"})
public void index(HttpServletResponse response) throws IOException {
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Developer developer = new Developer(systemFile, userDetails.getUsername());
File[] files = systemFile.getWwwDir().listFiles();
......@@ -91,12 +92,13 @@ public class IndexController {
"\t\t})");
html.append("</script>");
html.append("</html>");
logger.info(html.toString());
return html.toString();
response.setContentType("text/html;charset=UTF-8");
response.getOutputStream().write(html.toString().getBytes("UTF-8"));
// return html.toString();
}
@ResponseBody
@GetMapping("del/{project}")
@GetMapping("/del/{project}")
public void del(@PathVariable("project") String project, HttpServletResponse response) throws IOException {
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Developer developer = new Developer(systemFile, userDetails.getUsername());
......
......@@ -2,3 +2,4 @@ spring.application.name=site-server
server.port=51420
spring.servlet.multipart.max-file-size=256MB
workspace=${java.io.tmpdir}/.site-server
spring.http.encoding.force=true
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 sign in to comment