I have spring boot mvc with a little jpa back for training in this system. I have stylese with connected via thymeleaf links:
<link rel="stylesheet" data-th-href="@{/bs/dist/css/bootstrap.css}">
<link rel="stylesheet" data-th-href="@{/htmlElements/myElements.css}">
this is my project structure
Yesterday everything was working fine, but today I don't see my styles at all. After some researches I get this data:
- direct link to http://localhost:8080/htmlElements/myElements.css do not response.
next I restarted my app with DEBUG enabled, and saw that
2018-06-03 12:52:42.957 DEBUG 10888 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/bs/dist/css/bootstrap.css] 2018-06-03 12:52:42.957 DEBUG 10888 --- [nio-8080-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /bs/dist/css/bootstrap.css 2018-06-03 12:52:42.958 DEBUG 10888 --- [nio-8080-exec-3] o.s.b.w.s.f.OrderedRequestContextFilter : Bound request context to thread: org.apache.catalina.connector.RequestFacade@1298ec89 2018-06-03 12:52:42.958 DEBUG 10888 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/htmlElements/myElements.css] 2018-06-03 12:52:42.958 DEBUG 10888 --- [nio-8080-exec-3] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /htmlElements/myElements.css 2018-06-03 12:52:42.963 DEBUG 10888 --- [nio-8080-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported 2018-06-03 12:52:42.963 DEBUG 10888 --- [nio-8080-exec-3] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported 2018-06-03 12:52:42.963 DEBUG 10888 --- [nio-8080-exec-2] .w.s.m.a.ResponseStatusExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported 2018-06-03 12:52:42.963 DEBUG 10888 --- [nio-8080-exec-3] .w.s.m.a.ResponseStatusExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported 2018-06-03 12:52:42.964 DEBUG 10888 --- [nio-8080-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported 2018-06-03 12:52:42.964 WARN 10888 --- [nio-8080-exec-3] o.s.web.servlet.PageNotFound : Request method 'GET' not supported 2018-06-03 12:52:42.964 DEBUG 10888 --- [nio-8080-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported 2018-06-03 12:52:42.964 WARN 10888 --- [nio-8080-exec-2] o.s.web.servlet.PageNotFound : Request method 'GET' not supported 2018-06-03 12:52:42.964 DEBUG 10888 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling 2018-06-03 12:52:42.964 DEBUG 10888 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
So, i can't understand what the matter. I do not touch any spring boot autoconfig things. I think i should reconfigure WebMvcConfigurer.class with addResourceHandlers() its method, but i cant find correct guide how to realise it with spring boot.
I can make css like usual @GetMapping with proper position at "/templates", but it bad idea?
UPDATE | PARTIALLY SOLVED i found 1 contoller with @PostMapping without value. Remove it.Restart - styles appears. Then I add this @PostMapping() to the method of @Controller class and do not see those bug. So if anyone get the same problem: restart ide -> then check ur controllers. thx 4 help guys