简体   繁体   中英

Spring Boot not serving static javascript file

I have a very strange behaviour of Spring Boot application (1.4.0.RELEASE)

My static content lies under /src/main/resources/static/* and one of the pages needs css and js files, but despite the fact that css files are served without problems I am getting 404 for js files:

For CSS file I see in the logs

SimpleUrlHandlerMapping  : No handler mapping found for [/admin_files/custom_admin.css]
RequestMappingHandlerMapping : Looking up handler method for path /admin_files/custom_admin.css
RequestMappingHandlerMapping : Did not find handler method for [/admin_files/custom_admin.css]
SimpleUrlHandlerMapping: Matching patterns for request [/admin_files/custom_admin.css] are [/**]
SimpleUrlHandlerMapping  : Mapping [/admin_files/custom_admin.css] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], (...)

so it looks completely fine. However for JS file it looks different:

SimpleUrlHandlerMapping  : No handler mapping found for [/admin_files/vendor/jquery/dist/jquery.min.js]
RequestMappingHandlerMapping : Did not find handler method for [/admin_files/vendor/jquery/dist/jquery.min.js]
SimpleUrlHandlerMapping  : Matching patterns for request [/admin_files/vendor/jquery/dist/jquery.min.js] are [/**]
SimpleUrlHandlerMapping  : Mapping [/admin_files/vendor/jquery/dist/jquery.min.js] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/] (...)
//
// and now something strange starts to happen BELOW
//
HttpEntityMethodProcessor  : Written [{timestamp=Tue Sep 13 23:17:12 CEST 2016, status=404, error=Not Found, message=No message available, path=/admin_files/vendor/jquery/dist/jquery.min.js}] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@29139aae]

I am really stuck as it looks like a very small glitch or something very tiny that I am missing somewhere.

My application looks like this:

@SpringBootApplication
@EnableAsync
@EnableTransactionManagement(proxyTargetClass = true)
@EnableEncryptableProperties
public class Application extends WicketBootSecuredWebApplication { }

without any custom configuration beans, etc.

tree executed in /src/main/resources :

.
├── application-dev.yml
├── application-prod.yml
├── application-staging.yml
├── application.yml
├── banner.txt
└── static
    └── admin_files
        ├── custom_admin.css
        └── vendor
            ├── jquery
            │   ├── jquery.js
            │   └── jquery.min.js
            └── metisMenu
                ├── metisMenu.css
                ├── metisMenu.js
                ├── metisMenu.min.css
                └── metisMenu.min.js

Any help appreciated!

注意,您要的是/ admin_files / vendor / jquery / dist /jquery.min.js,但是在资源树中dist目录不存在。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM