嗨映射css不起作用。
这是我的配置:
弹簧servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<context:component-scan base-package="spring.controllers" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/content/" />
<property name="suffix" value=".jsp" />
</bean>
<context:component-scan base-package="it.jsoftware.jacciseweb.controllers"></context:component-scan>
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/js/**" location="/js/" />
网页.xml:
<?xml version="1.0" encoding="UTF-8"?>
<display-name>JewishProjectT</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
和我的 heder 文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<c:choose>
<c:when test="${sessionScope['org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE'] eq 'i18en'}">
<c:set var="approach" value="left" scope="page"></c:set>
</c:when>
<c:when test="${sessionScope['org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE'] eq 'i18ru'}">
<c:set var="approach" value="left" scope="page"></c:set>
</c:when>
<c:when test="${sessionScope['org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE'] eq 'i18he'}">
<c:set var="approach" value="right" scope="page"></c:set>
</c:when>
<c:otherwise>
<c:set var="approach" value="left"></c:set>
</c:otherwise>
</c:choose>
<link rel="stylesheet" media="all" type="text/css" href="/css/common.css">
<link rel="stylesheet" media="all" type="text/css" href="/css/lavamenu.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/<c:out value="${approach}"/>/lavalamp.js"></script>
<title>${title}</title>
</head>
<body>
<div id="main">
在 chrome 中它显示:
/js/left/lavalamp.js 404(未找到)0:19 GET
/css/common.css 404(未找到)0:17 GET
/css/lavamenu.css 404(未找到)
如何正确配置 css/images/js 的路径?
PS我排除了所有以 http:\\ 开头的链接,因为stackoverflow的规则不允许我发布它们,因为我是初学者。