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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:22:43+00:00 2026-06-15T05:22:43+00:00

I am new to spring and am trying it. I have a jsp file

  • 0

I am new to spring and am trying it.

I have a jsp file which includes css and images as follows

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

Now i have a url path as /localhost/myapp/test/tst which is mapped to a controller which then forwards it to view jsp

view.jsp is present it

/web-inf/jsp/view.jsp

But when hit the path /localhost/myapp/test/tst the css and images path gets resolved to

/localhost/myapp/test/tst/css/style.css

Actaully i want it to come as /localhost/myapp/css/style.css
css and html are present in root of webapp

How i have following in my spring config

 <mvc:annotation-driven />
    <mvc:resources mapping="/images/**" location="/images/" />
    <mvc:resources mapping="/css/**" location="/css/" />
  • 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-15T05:22:44+00:00Added an answer on June 15, 2026 at 5:22 am

    Your CSS href is currently relative to your page, you need to make it relative to the server root by adding a leading slash (plus context, etc). Its also a good idea to add the contextPath so that if/when you change the webapp name or deploy it as a root webapp, the resources still work.

    <link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a programmer, new to jsp, trying to write some code. i have
I have been trying out the new Spring MVC 3.0 Type Conversion Framework. I
I'm new to Spring and trying to use the Spring Formatting SPI for UI
Im quite new to spring mvc. What I'm trying to achive is separating static
I am trying to create a new date object from string as follows: var
I am new to Spring MVC . I have a web application. I have
Here is my problem, I have user accounts created from java(jsp) interface which uses
I am new to spring and trying to understand the functionality of the idref
I'm really new to web developing...I'm trying to draw area graph on JSP (this
i am new to web programming. i am trying to connect database using jsp

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.