Java Spring无法找到资源
我看了所有的回答,但似乎无法解决我的问题。我无法将我的资源css文件导入jsp。我的资源位于main/webapp/resources/** 这是我的档案: web.xml:Java Spring无法找到资源,java,spring,jsp,spring-mvc,servlets,Java,Spring,Jsp,Spring Mvc,Servlets,我看了所有的回答,但似乎无法解决我的问题。我无法将我的资源css文件导入jsp。我的资源位于main/webapp/resources/** 这是我的档案: web.xml: <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xm
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- For web context -->
<servlet>
<servlet-name>geodispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/geomonitor-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>geodispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>logbackConfigLocation</param-name>
<param-value>/WEB-INF/logback.xml</param-value>
</context-param>
我的jsp中有以下行要导入资源:
<link href="/resources/css/styles.css" rel="stylesheet">
要在JSP页面中包含CSS或JS,可以使用JSTL标记
c:url
或Spring标记Spring:url
<link href="<c:url value="/resources/css/styles.css" />" rel="stylesheet">
<spring:url value="/resources/css/styles.css" var="mainCss" />
<link href="${mainCss}" rel="stylesheet" />
<link href="/resources/css/styles.css" rel="stylesheet">
<link href="<c:url value="/resources/css/styles.css" />" rel="stylesheet">
<spring:url value="/resources/css/styles.css" var="mainCss" />
<link href="${mainCss}" rel="stylesheet" />