解决 "https" redirect之后跳转 "http" 问题

master
zhaolong@sunlands.com 4 years ago
parent 289f02185b
commit 49ed124baa
  1. 9
      xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java
  2. 4
      xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java

@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -51,11 +53,12 @@ public class IndexController {
@RequestMapping("/toLogin") @RequestMapping("/toLogin")
@PermissionLimit(limit=false) @PermissionLimit(limit=false)
public String toLogin(HttpServletRequest request, HttpServletResponse response) { public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response,ModelAndView modelAndView) {
if (loginService.ifLogin(request, response) != null) { if (loginService.ifLogin(request, response) != null) {
return "redirect:/"; modelAndView.setView(new RedirectView("/",true,false));
return modelAndView;
} }
return "login"; return new ModelAndView("login");
} }
@RequestMapping(value="login", method=RequestMethod.POST) @RequestMapping(value="login", method=RequestMethod.POST)

@ -43,8 +43,8 @@ public class PermissionInterceptor extends HandlerInterceptorAdapter {
if (needLogin) { if (needLogin) {
XxlJobUser loginUser = loginService.ifLogin(request, response); XxlJobUser loginUser = loginService.ifLogin(request, response);
if (loginUser == null) { if (loginUser == null) {
response.sendRedirect(request.getContextPath() + "/toLogin"); response.setStatus(302);
//request.getRequestDispatcher("/toLogin").forward(request, response); response.setHeader("location", request.getContextPath()+"/toLogin");
return false; return false;
} }
if (needAdminuser && loginUser.getRole()!=1) { if (needAdminuser && loginUser.getRole()!=1) {

Loading…
Cancel
Save