0

Now I work on the web-project java using Spring Framework. And I came across very strange thing, that I can't resolve on my own. I use such servlet -mapping in web.xml:

<?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>

If I change url-pattern in servlet-mapping to *.htm, my css is successfully linked. But with this pattern I can't make paging,so I can't accept this type.

I've tried such ways of linking 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">

Please help me! My brain's going to blow up)

RGLSV
  • 2,018
  • 1
  • 22
  • 37
Mary
  • 3
  • 1

1 Answers1

0

The problem is with the restless url patterns . Allow the resources in the web.xml,

<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/css/*</url-pattern>
</servlet-mapping>
Santhosh
  • 8,181
  • 4
  • 29
  • 56
  • Would allowing everything with a "*" cause problems? – Arthur Eirich Jan 30 '15 at 12:02
  • yes , refer this http://stackoverflow.com/questions/1483063/spring-mvc-3-and-handling-static-content-am-i-missing-something – Santhosh Jan 30 '15 at 12:05
  • But you suggest editing another one servlet-mapping to web.xml, and I tried it. But because of two servlet-mappings it doesn't deploy:( – Mary Jan 30 '15 at 14:47