Marek Borecki
Marek Borecki

Reputation: 440

SpringBoot redirect to site 404

I've created some application in SpringBoot… I've created css and html files, and everything wrork, but and I have some problem with redirect wrong. When I've wrote method with annotation @RequestMapping to redirect all wrongs links to prepared 404 site, my application has lost path to css files and all sites are unstyled.

@Controller
public class MainController {

    @GetMapping("/status/ping")
    @ResponseBody
    public String pingPong() {
        ModelAndView mav = new ModelAndView("pong");
        return mav;
    }

    @GetMapping("/")
    @RequestMapping
    public ModelAndView error404(){
        ModelAndView mav = new ModelAndView("error404");
        return mav;
    }

without error404() method browser display site with css file but when I wrote this method css unworks, but when i go to site localhost:8080/status/kjhfkshfds

website display my 404 site

Upvotes: 1

Views: 154

Answers (1)

Royts
Royts

Reputation: 511

Do you have this on your SecurityConfig class?

http.authorizeRequests()
            .antMatchers(HttpMethod.GET, "/js/**", "/css/*", "/images/**").permitAll()

Upvotes: 2

Related Questions