Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Spring MVC 3.2.6中导入/使用WebJAR?_Java_Spring_Spring Mvc_Webjars - Fatal编程技术网

Java 如何在Spring MVC 3.2.6中导入/使用WebJAR?

Java 如何在Spring MVC 3.2.6中导入/使用WebJAR?,java,spring,spring-mvc,webjars,Java,Spring,Spring Mvc,Webjars,我无法在我的SPring MVC 3.2.6+Tomcat7项目中使用font awesome.4.0 Webjar。但是我可以通过CDN使用,尽管我不需要依赖项 pom.xml <dependency> <groupId>org.webjars</groupId> <artifactId>font-awesome</artifactId> <version>4.4.0</version&

我无法在我的SPring MVC 3.2.6+Tomcat7项目中使用font awesome.4.0 Webjar。但是我可以通过CDN使用,尽管我不需要依赖项

pom.xml

<dependency>
     <groupId>org.webjars</groupId>
     <artifactId>font-awesome</artifactId>
     <version>4.4.0</version>
</dependency>

org.webjars

我还试着使用weblocater

<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.1</version>

org.webjars
webjars定位器
0.1

在servlet-config.xml和my login.jsp中提供的资源中,我使用下面的

<link rel='stylesheet' href='<%= org.webjars.AssetLocator.getWebJarPath("css/font-awesome.css") %>'>

请查找下面的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern> 
</filter-mapping>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/config/security-config.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
    <servlet-name>taskManagementServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/config/servlet-config.xml</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>taskManagementServlet</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>taskManagementServlet</servlet-name>
    <url-pattern>*.json</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>taskManagementServlet</servlet-name>
    <url-pattern>/pdfs/**</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>1</session-timeout> 
</session-config>
</web-app>

springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/* 
上下文配置位置
/WEB-INF/config/security-config.xml
org.springframework.web.context.ContextLoaderListener
taskManagementServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/config/servlet-config.xml
taskManagementServlet
*.html
taskManagementServlet
*.json
taskManagementServlet
/PDF/**
1.

请指导我更正错误。

您的servlet容器的版本是什么?或者更好的是,部署描述符(
web.xml
)的版本是什么?配置在我看来很好…运气不好,我尝试了,但仍然无法在屏幕上看到图标。这是有效的:
在我的项目中…是的,我尝试了这个,在问题本身中,我指定它不起作用。在chrome控制台中,我看到以下URL
看看这个…我已经在使用webjars;你可以玩它。就像我说的,你的配置看起来很好。。。
<link href="<c:url value='/webjars/font-awesome/4.4.0/css/font-awesome.css' />" rel="stylesheet">
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.1</version>
<link rel='stylesheet' href='<%= org.webjars.AssetLocator.getWebJarPath("css/font-awesome.css") %>'>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern> 
</filter-mapping>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/config/security-config.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
    <servlet-name>taskManagementServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/config/servlet-config.xml</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>taskManagementServlet</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>taskManagementServlet</servlet-name>
    <url-pattern>*.json</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>taskManagementServlet</servlet-name>
    <url-pattern>/pdfs/**</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>1</session-timeout> 
</session-config>
</web-app>