skip to Main Content

My first time I created from origin a web-app and I’m new on Spring MVC.
I created a Spring MVC project and works as well. Now I want to add twitter-bootsrrap and jquery to my project and use these. Bu I don’t know ho can I do that?

I use Intellij Idea.

I’ve to download bootstrap and jquery files and add to project not from the link source.

I’m using Spring MVC 4. Because of that I don’t use xml files for Spring configuration. I use anotations.

Could you help me please?

2

Answers


  1. If you want to use the downloaded files take a look at Spring MVC – How to include JS or CSS files in a JSP page

    If you use maven take a look at webjars.
    Also search abit more here on stackoverflow. A lot of questions regarding this already…

    webjars-in-spring-mvc

    Login or Signup to reply.
  2. add this line in your class config :

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

    in src/main/webapp/ create folders resources and add css js to this folder .

    in your page jsp apply your css and js like this using jstl :

    <%@taglib  uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
    
        <link href="<c:url value="/resources/bootstrap/dist/css/bootstrap.min.css" />" rel="stylesheet">
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search