0

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?

luffy
  • 315
  • 1
  • 4
  • 22

2 Answers2

0

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

pressbyron
  • 307
  • 1
  • 2
  • 12
  • Firstly thank you for your interest. I use Intellij as a IDE and maven projectcreated resource package under the src folder. Have I to create a new resource folder under the webapp? Secondly I do not use xml files for Spring configurations I use anotation. So How I do this things on anotation? – luffy May 02 '17 at 18:38
  • Look at [link](http://www.webjars.org/documentation#springmvc). Should be something like `@Configuration @EnableWebMvc public class WebConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); } }` Im not sure how to properly format comments, sorry! :) – pressbyron May 03 '17 at 07:28
0

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">
hicham abdedaime
  • 346
  • 2
  • 15
  • Have I to mark resource which under the webapp as resource directory? Because Intellij create a resource directory under the src and I created properties files at. – luffy May 03 '17 at 06:27
  • Ok well done. Thank you for your interest. I clicked on your answer. Thank you. – luffy May 03 '17 at 07:03