Use the spring security to do permission control when Access does not have permission to jump to the default 403 page of the transfer. Does not meet current project requirements.
is the solution:
PackageCom.ycmedia;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.EnableAutoConfiguration;Importorg.springframework.boot.autoconfigure.SpringBootApplication;ImportOrg.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;ImportOrg.springframework.boot.context.embedded.ErrorPage;ImportOrg.springframework.context.annotation.Bean;ImportOrg.springframework.http.HttpStatus;ImportOrg.springframework.security.core.userdetails.UserDetailsService;ImportOrg.springframework.web.servlet.config.annotation.ViewControllerRegistry;ImportOrg.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;ImportCom.ycmedia.service.UserService, @SpringBootApplication @enableautoconfiguration Public classApplicationextendsWebmvcconfigureradapter {@Bean PublicUserdetailsservice Userdetailsservice () {return NewUserService (); } /*** Custom Exception page*/@Bean PublicEmbeddedservletcontainercustomizer Containercustomizer () {return(Container{errorpage Error401page=NewErrorPage (Httpstatus.forbidden, "/403.html"); ErrorPage Error404page=NewErrorPage (Httpstatus.not_found, "/404.html"); ErrorPage Error500page=NewErrorPage (Httpstatus.internal_server_error, "/500.html"); Container.adderrorpages (Error401page, Error404page, error500page); }); } @Override Public voidaddviewcontrollers (Viewcontrollerregistry registry) {} Public Static voidMain (string[] args) {springapplication.run (application.class, args); }}
See on the net what realizes Accessdeniedhandler, seem not good use.
Spring Security +spring Boot Custom 403 page