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 8009115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:21:03+00:00 2026-06-04T18:21:03+00:00

I have a problem with handling css files in Spring MVC. Something is wrong

  • 0

I have a problem with handling css files in Spring MVC. Something is wrong with the location and mapping of the css file.

If the css file is in:

-src
  -main
     +java
     +resources
     -webapp
        -css
           style.css
        +WEB-INF

(Maven project)

I use:

 <mvc:resources location="/css/" mapping="/css/**"/>
 <mvc:annotation-driven/> 

in dispatcher-servlet.xml, and access access it in the jsp with:

<head>
  <title>Insert title here</title>
  <link href="/css/style.css" rel="stylesheet" type="text/css">
</head>
  • 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-04T18:21:05+00:00Added an answer on June 4, 2026 at 6:21 pm

    To solve this problem so that your code will run with the actual paths you would use in production, use a <base> tag in your JSP pages, like so:

    <base href="http://localhost:8081/table/" target="_blank" />
    

    This will ensure that all of the rest of the relative paths in your JSP page can be represented using the full paths:

    <link href="/css/style.css" rel="stylesheet" type="text/css">
    

    For further reading, here is a reference at the Mozilla Developer Center on the usage of the HTML base element. Additionally, this blog post may also be helpful in giving you a perspective on working with client-side code, especially if you work with Web designers who are not Java developers.


    NOTE: As an aside, if you combine @gigadot’s proposed solution to use c:url tags with the base tag, then it will save you the trouble of needing to edit every single link on your site and cluttering the HTML, while still making the base tag be dynamic so that if you change the context path, it will still be reflected everywhere, but in a manner that doesn’t bind you so tightly to the framework.

    I’m linking to that answer so that the credit for using the <c:url tag goes to @gigadot, yet documenting it here so that others can benefit from the combined knowledge of using both together.

    <base href="<c:url value='/table' />" target="blank" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the next problem with wicket and standard error handling: all the css
I have a problem with file handling. I'm writing code for file handling, that
I have a problem with slashes! I have some jQuery for handling generic dialogs
I experience strange problem. We have error handling in global.asax that would redirect user
I have a problem handling messages in a Thread. My run-method looks like this
I am using windows forms. I have a problem in handling mouse events. In
I have a problem with handling json variables in javascript. The problem appears when
I'm using the MailSystem.NET OS library for handling IMAP. I have a problem with
I have a problem with jQuery click event handling. Here's my code: $j(#btn_renommer_groupe).click(function(){ document.forms['creation_edition_groupe'].reset();
I'm using local notification in my app but have a problem handling them correctly.

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.