whycxzp
2021-01-11 15152da2f87438747c519adcb6237093b34ae2b4
src/main/java/com/whyc/controller/LoginController.java
@@ -6,6 +6,8 @@
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.ServletException;
@@ -33,10 +35,24 @@
        service.logout();
    }
    /**拦截登录*/
    @GetMapping("login")
    /**拦截登录*//*
    @GetMapping("/")
    @ApiIgnore
    public void login(){
        System.out.printf("请登录...");
    public ModelAndView toLoginHtml(HttpServletRequest request, HttpServletResponse response,ModelAndView view) throws ServletException, IOException {
        //request.getRequestDispatcher("login.html").forward(request,response);
        System.out.println("转发啦...");
        //response.setContentType("text/html;charset=utf-8");
        //response.sendRedirect("http://localhost:8090/login.html");
        //response.sendRedirect("/login.html");
        view.setViewName("login");
        return view;
    }*/
    /**拦截登录*/
    @GetMapping("unauthorized")
    @ApiIgnore
    public void unauthorized(HttpServletRequest request,HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write("您未获取到接口的调用授权,拒绝访问!");
    }
}