1

I have a Spring project:

Resource files are under : src/main/resources/style/.........lots of subfolders

servlet.xml:

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

and my jsp:

<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css"/>

When I browse to my view, gives this link as location:

http://localhost:8080/webapp/WEB-INF/classes/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css

How can I get it to show css file correctly?

1 Answer 1

4

The standard Maven layout has web resources located in src/main/webapp/resources. The src/main/resources is more for library and Java resources.

Referencing them in your JSP is easily done with the JSTL core c:url tag. You don't need to worry about context root when using these. For example:

<link rel="stylesheet" href="<c:url value="/resources/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css" />" />

The library will automatically prepend the context root to this URL.

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.