我正在使用Spring Boot 2.1.6.RELEASE,Thymeleaf 3,Spring Security
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
/**
* Configuration for overall application.
*/
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class WebConfig extends WebMvcConfigurationSupport {
@Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/templates/");
resolver.setSuffix(".html");
return resolver;
}
/**
* Static resources.
*
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// Register resource handler for CSS and JS.
registry.addResourceHandler("/resources/**")
.addResourceLocations("classpath:/statics/", "D:/statics/")
.setCacheControl(CacheControl.maxAge(2, TimeUnit.HOURS).cachePublic());
// Register resource handler for images.
registry.addResourceHandler(
"/images/**",
"/css/**",
"/js/**"
)
.addResourceLocations(
"classpath:/static/images/",
"classpath:/static/css/",
"classpath:/static/js/"
)
.setCacheControl(CacheControl.maxAge(2, TimeUnit.HOURS).cachePublic());
}
}
在header.html
(胸腺模板文件)中
<script type="text/javascript" th:src="@{/js/kendo.messages.vi-VN.js}"><!--this file cannot load--></script>
<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/js/kendo.all.min.js}"></script>
3个JavaScript文件:/js/kendo.messages.vi-VN.js
,/js/jquery.min.js
和/js/kendo.all.min.js
我放在同一目录中。
文件/js/jquery.min.js
和/js/kendo.all.min.js
加载成功。文件/js/kendo.messages.vi-VN.js
无法访问
在IDE中
在Firefox Web浏览器控制台上
https://github.com/donhuvy/kendo-ui-core/blob/master/src/cultures/kendo.culture.vi-VN.js之类的文件内容
如何解决?