【发布时间】:2015-01-30 20:01:06
【问题描述】:
现在我使用 Spring Framework 处理 web 项目 java。我遇到了非常奇怪的事情,我无法自己解决。 我在 web.xml 中使用了这样的 servlet 映射:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
如果我将 servlet-mapping 中的 url-pattern 更改为 *.htm,我的 css 链接成功。但是用这种模式我不能进行分页,所以我不能接受这种类型。
我尝试过这种链接css的方式:
<c:set var="root" value="${pageContext.request.contextPath}" />
<link href="${root}/css/bootstrap.css" rel="stylesheet">`
<link href="<c:url value="/css/bootstrap.css"/>" rel="stylesheet" type="text/css">
请帮帮我!我的脑袋要炸了)
【问题讨论】:
-
试试
/* -
你可以从这里stackoverflow.com/questions/28188389/…尝试答案