Java 我无法将css文件链接到我的项目
现在,我使用Spring框架处理web项目java。我遇到了一件很奇怪的事情,我自己无法解决。 我在web.xml中使用这样的servlet映射:Java 我无法将css文件链接到我的项目,java,html,css,xml,spring,Java,Html,Css,Xml,Spring,现在,我使用Spring框架处理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://j
<?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映射中的url模式更改为*.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">
请帮帮我!我的大脑要崩溃了,问题在于不安的url模式。允许web.xml中的资源
try/*您可以从这里尝试答案,是否允许所有带有*的内容都会导致问题?是的,请参考此内容,但您建议编辑另一个映射到web.xml的servlet,我尝试了。但由于有两个servlet映射,它没有部署:
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/css/*</url-pattern>
</servlet-mapping>