0

I am unable to load JS and CSS file from webcontent folder.My login page goes without formatting please suggest me how to load this I am not using maven. Plz find the image.enter image description here enter image description here

1
  • 2
    I believe it should go in the resources folder Commented May 19, 2017 at 9:21

1 Answer 1

1

1) Create "resources" folder.

2) Add this in your xml file:

<mvc:resources mapping="/resources/**" location="/resources/" />

3)"Use" it in your page:

<link href="<c:url value="/resources/name_of_file.css" />" rel="stylesheet">

If you use Java Config, something like this will do the job:

@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
          .addResourceHandler("/resources/**")
          .addResourceLocations("/resources/"); 
    }
}
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.