You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.8 KiB
59 lines
1.8 KiB
package com.zky.bjca.cert.controller;
|
|
import org.springframework.core.io.FileSystemResource;
|
|
import org.springframework.core.io.Resource;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import java.io.IOException;
|
|
|
|
@Controller
|
|
public class loginController {
|
|
@Controller
|
|
public class LoginController {
|
|
|
|
@GetMapping("/login")
|
|
public String showLoginForm() {
|
|
return "login";
|
|
}
|
|
|
|
@PostMapping("/login")
|
|
public String login(@RequestParam("value") String value) {
|
|
if (value.equals("证书登录成功") ) {
|
|
return "redirect:/home";
|
|
} else {
|
|
return "login.html";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/static/xtxasyn.js")
|
|
public ResponseEntity<Resource> downloadFile() throws IOException {
|
|
Resource fileResource = new FileSystemResource("src/main/resources/static/xtxasyn.js"); // 替换为你的文件路径
|
|
|
|
if (!fileResource.exists()) {
|
|
throw new IllegalArgumentException("File not found");
|
|
}
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileResource.getFilename());
|
|
|
|
return ResponseEntity.ok()
|
|
.headers(headers)
|
|
.contentLength(fileResource.contentLength())
|
|
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
|
.body(fileResource);
|
|
}
|
|
|
|
|
|
}
|
|
}
|