大佬教程收集整理的这篇文章主要介绍了Spring Boot Webjars:无法通过Webjar加载JavaScript库,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
您正在正确引用jquery库。也许您缺少资源处理程序配置。
<mvc:@R_675_5550@es mapPing="/webjars/**" LOCATIOn="classpath:/meta-inf/@R_675_5550@es/webjars/"/>
或者,如果您使用JavaConfig
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@OverrIDe
public voID add@R_675_5550@eHandlers(@R_675_5550@eHandlerRegistry registry) {
registry.add@R_675_5550@eHandler("/webjars/**").add@R_675_5550@eLOCATIOns("classpath:/meta-inf/@R_675_5550@es/webjars/");
}
}
Webjars文档
如果这不起作用,请检查类路径上是否有webjar(在7Zip中打开应用程序JAR,并检查其中是否包含webjar资源)。
我有一个Spring Boot(我使用Thymeleaf进行模板制作)项目,我想使用一些jQuery库。
不幸的是,webjar根本没有加载。我尝试了许多配置,但所有配置均失败。
这是我的HTML页面的代码片段:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<title>JAC</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script src="http://cdn.jsdelivr.net/webjars/jquery/2.1.4/jquery.js"
th:src="@{/webjars/jquery/2.1.4/jquery.min.js}" type="text/javascript"></script>
<script src="http://cdn.jsdelivr.net/webjars/jquery-file-upload/9.10.1/jquery.fileupload.js" type="text/javascript"
th:src="@{/webjars/jquery-file-upload/9.10.1/jquery.fileupload.min.js}"></script>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.5/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.5/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
<link href="http://cdn.jsdelivr.net/webjars/jquery-file-upload/9.10.1/jquery.fileupload.css"
rel="stylesheet" media="screen" />
</head>
我已经将它们添加到pom文件中:
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>jquery</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery-file-upload</artifactId>
<version>9.10.1</version>
</dependency>
但是当调用页面时,在jquery.min.js和jquery.fileupload.min.js上得到了404。
GET http://localhost:8888/webjars/jquery-file-upload/9.10.1/jquery.fileupload.min.js
2015-09-21 02:02:04.059 home:9
GET http://localhost:8888/webjars/jquery/2.1.4/jquery.min.js 404 (Not Found)
以上是大佬教程为你收集整理的Spring Boot Webjars:无法通过Webjar加载JavaScript库全部内容,希望文章能够帮你解决Spring Boot Webjars:无法通过Webjar加载JavaScript库所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。