现在我使用Spring Framework处理web项目java。我遇到了一件非常奇怪的事情,我无法靠自己决定。 我在web.xml中使用了这样的servlet -mapping:
<?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">
请帮帮我!我的大脑会爆炸)
答案 0 :(得分:0)
问题在于不安定的url
模式。允许web.xml
,
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/css/*</url-pattern>
</servlet-mapping>