我无法将font-awesome.4.4.0 webjars用于我的SPring MVC 3.2.6 + Tomcat7项目。但我可以通过CDN使用,但我不想要依赖。
的pom.xml
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>4.4.0</version>
</dependency>
在servlet-config.xml中,我有以下代码,
<mvc:resources location="pdfs" mapping="/pdfs/**" />
<mvc:resources mapping="/resources/**" location="/resources/theme1/"/>
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
在我的login.jsp中,我试图访问如下所示的font-awesome.css,
<link href="/webjars/font-awesome/4.4.0/css/font-awesome.css" rel="stylesheet" />
(或)
<link href="${pageContext.request.contextPath}/webjars/font-awesome/4.4.0/css/font-awesome.css" rel="stylesheet" />
(或)
<link href="<c:url value='/webjars/font-awesome/4.4.0/css/font-awesome.css' />" rel="stylesheet">
我按照以下链接但没有运气,
我也尝试使用weblocater,
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.1</version>
在servlet-config.xml和我的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>
请指导我纠正错误。