1

I'm working on a project in Spring MVC. I would like to connect CSS and js under it. However, for some reason, spring can not see these files. In the previous project which was configured using XML and everything worked fine. Any suggestion would be helpful.

Project Structure

    <script type="text/javascript" src='<spring:url value="/resources/js/script.js"/>'></script>
    <link href='<spring:url value="/resources/css/style.css"/>' rel="stylesheet" />

Configuration:

public void addResourceHandlers(final ResourceHandlerRegistry registry){
    registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
0

1 Answer 1

1

Move the resource folder under webapp folder. And with this line you can connect your css file.

<link rel="stylesheet" href="/css/styles.css"> 

Similarly write code to connect script like

<script type="text/javascript" src="/js/script.js"></script>
Sign up to request clarification or add additional context in comments.

1 Comment

@Voler My pleasure !

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.