From b963721be1fdce2328ca0df17bed71605807ce26 Mon Sep 17 00:00:00 2001 From: 05412 Date: Thu, 18 Jul 2024 14:59:31 +0800 Subject: [PATCH] =?UTF-8?q?302=E8=B7=B3=E8=BD=AC=E9=99=84=E5=8A=A0?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/dev/surl/surl/controller/RedirectController.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/surl/surl/controller/RedirectController.kt b/src/main/java/dev/surl/surl/controller/RedirectController.kt index be95535..9def47d 100644 --- a/src/main/java/dev/surl/surl/controller/RedirectController.kt +++ b/src/main/java/dev/surl/surl/controller/RedirectController.kt @@ -5,6 +5,7 @@ import dev.surl.surl.service.SurlService import jakarta.validation.Valid import jakarta.validation.constraints.Pattern import org.hibernate.validator.constraints.Length +import org.springframework.http.HttpHeaders import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping @@ -36,7 +37,9 @@ class RedirectController(private val service: SurlService) { ResponseEntity(Msg(code = -1, msg = "key `$key` not found"), HttpStatus.NOT_FOUND) } else { // 找到,发送302跳转 - ResponseEntity.status(302).location(URI.create(redirectUrl)).build() + ResponseEntity(Msg(msg = "FOUND"), HttpHeaders().apply { + location = URI.create(redirectUrl) + }, HttpStatus.FOUND) } } } \ No newline at end of file