Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8466063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:13:55+00:00 2026-06-10T15:13:55+00:00

Hi mapping css doesn’t work. This is my config: spring-servlet.xml: <?xml version="1.0" encoding="UTF-8"?> <context:component-scan

  • 0

Hi mapping css doesn’t work.

This is my config:

spring-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/" />  
    

web.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>

and my heder file:

<!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">

in chrome it shows:

/js/left/lavalamp.js 404 (Not Found) 0:19 GET

/css/common.css 404 (Not Found) 0:17 GET

/css/lavamenu.css 404 (Not Found)

How to correctly configure paths to css/images/js?

P.S. I excluded all links which starts with http:\\ , because rules of stackoverflow do not permit me post them as I am beginner.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:13:57+00:00Added an answer on June 10, 2026 at 3:13 pm

    Your <mvc:resources mapping="/css/**" location="/css/" /> seems fine to me, but are you sure your application is running in the root? Shouldn’t your URLs start with some other context, like:

    href="/myapp/css/common.css"
    

    Or, to avoid hardcoded references:

    href="<c:url value="/css/common.css" />"
    

    If your application is running in the root, then you might need the correct namespace declarations? Something like:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xsi:schemaLocation="http://www.springframework.org/schema/mvc 
          http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
          http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this segment of XML: <mvc:interceptors> <mvc:interceptor> <mvc:mapping path=/statics/** /> <bean class=com.company.website.servlet.StaticsHandlerInterceptor />
My web.xml is: http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd id=WebApp_ID version=2.5> TestStruts2 <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name>
My filter mapping in web.xml is as follows: <filter> <filter-name>LoginCheckFilter</filter-name> <filter-class>com.tutorial.filter.LoginCheckFilter</filter-class> </filter> <filter-mapping> <filter-name>LoginCheckFilter</filter-name>
I have some troubles mapping a JSON Array to RestKit. This is what the
I trying to do circle hover area with mapping what must work in ie7,
This thing works for 4 of the 5 folders under _res. <mvc:resources mapping=/_res/** location=/_res//>
I would like to collect all css/js resources in a controller. This would result
I have the following URL pattern: <servlet-mapping> <servlet-name>name_of_a_servlet</servlet-name> <url-pattern>*.some_pattern</url-pattern> </servlet-mapping> If i have more
I'm using JSF2 and Richfaces 4. I've added the following to my web.xml: <mime-mapping>
I have a problem with handling css files in Spring MVC. Something is wrong

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.