Joburgess 5 years ago
parent
commit
54c2b8c2a1

+ 3 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ShortUrlController.java

@@ -10,8 +10,10 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.IOException;
+import java.net.URLEncoder;
 import java.util.Objects;
 import java.util.Objects;
 
 
 /**
 /**
@@ -32,7 +34,7 @@ public class ShortUrlController extends BaseController {
         if(Objects.isNull(shortUrl)|| StringUtils.isBlank(shortUrl.getUrl())){
         if(Objects.isNull(shortUrl)|| StringUtils.isBlank(shortUrl.getUrl())){
             return;
             return;
         }
         }
-        response.sendRedirect(shortUrl.getUrl());
+        response.sendRedirect(URLEncoder.encode(shortUrl.getUrl(), "GBK"));
     }
     }
 
 
 }
 }