3

I'm using @PathVariable to obtain some placeholder from the uri this is the function from my controller

@RequestMapping(value = "/mail_detail/{id}", method = RequestMethod.GET)
public String showCourrierDetail(@PathVariable("id") String id) {
    //System.out.println("id="+id);
    return "mail_detail";
}

It redirects me to jsp page named mail_detail My problem is that when I add the path variable, the jsp page don't read the css files although when I use

@RequestMapping(value = "/mail_detail", method = RequestMethod.GET)
public
 String showmail() {


    return "mail_detail";
}

It works and reads all the css files

9
  • can you tell me how your CSS <link> in your HTML looks like ? Commented May 23, 2017 at 14:08
  • they looks like this <link href="resources/css/bootstrap.min.css" rel="stylesheet"> Commented May 23, 2017 at 14:13
  • 2
    Ok. can you add a / before resources and check? It should look like - <link href="/resources/css/bootstrap.min.css" rel="stylesheet"> Commented May 23, 2017 at 14:15
  • no,didn't work for me Commented May 23, 2017 at 14:19
  • I think the problem isn't from the jsp file because it works perfectly for me on the other controllers but I don't know why while using a controller with a variable path on it ,it shows me the page without loading css files Commented May 23, 2017 at 14:22

1 Answer 1

3

if your file is a jsp file you may prefix ${pageContext.request.contextPath}in the URL, like <link href="${pageContext.request.contextPath}/resources/css/bootstrap.min.css" rel="stylesheet">.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.