{"id":1612,"date":"2016-10-04T17:24:21","date_gmt":"2016-10-04T15:24:21","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=1612"},"modified":"2016-10-04T17:24:59","modified_gmt":"2016-10-04T15:24:59","slug":"java-spring-webjars","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=1612","title":{"rendered":"Java Spring &#8211; Webjars"},"content":{"rendered":"<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Prerequistes\"><span class=\"toc_number toc_depth_1\">1<\/span> Prerequistes<\/a><\/li><li><a href=\"#Configuration\"><span class=\"toc_number toc_depth_1\">2<\/span> Configuration<\/a><ul><li><a href=\"#Dependencies\"><span class=\"toc_number toc_depth_2\">2.1<\/span> Dependencies<\/a><\/li><li><a href=\"#WebMvcConfigjava\"><span class=\"toc_number toc_depth_2\">2.2<\/span> WebMvcConfig.java<\/a><\/li><\/ul><\/li><li><a href=\"#jsp_view\"><span class=\"toc_number toc_depth_1\">3<\/span> jsp view<\/a><\/li><\/ul><\/div>\n<h1><span id=\"Prerequistes\">Prerequistes<\/span><\/h1>\n<p>Please read : <a href=\"?page_id=1549\">Java spring &#8211; quickstart<\/a><\/p>\n<h1><span id=\"Configuration\">Configuration<\/span><\/h1>\n<h2><span id=\"Dependencies\">Dependencies<\/span><\/h2>\n<p>If you use maven, add this to your pom.xml :<\/p>\n<pre lang=\"java\">\r\n<dependency>\r\n  <groupId>org.webjars<\/groupId>\r\n  <artifactId>webjars-taglib<\/artifactId>\r\n  <version>0.3<\/version>\r\n<\/dependency>\r\n\r\n<dependency>\r\n  <groupId>org.webjars<\/groupId>\r\n  <artifactId>jquery<\/artifactId>\r\n  <version>3.1.1<\/version>\r\n<\/dependency>\r\n\r\n<\/pre>\n<h2><span id=\"WebMvcConfigjava\">WebMvcConfig.java<\/span><\/h2>\n<p>In WebMvcConfig.java, add the ressouce :<\/p>\n<pre lang=\"java\">\r\n@Override\r\n  public void addResourceHandlers(ResourceHandlerRegistry registry) {\r\n    registry.addResourceHandler(\"\/webjars\/**\").addResourceLocations(\"\/webjars\/\");\r\n}\r\n<\/pre>\n<h1><span id=\"jsp_view\">jsp view<\/span><\/h1>\n<p>Import the following taglib:<\/p>\n<pre>\r\n<%@ taglib uri=\"http:\/\/www.webjars.org\/tags\" prefix=\"wj\"%>\r\n<\/pre>\n<p>Then locate the file in the webjar :<\/p>\n<pre lang=\"xml\">\r\n<script src=\"<wj:locate path=\"jquery.min.js\" \/>\"><\/script>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 Prerequistes2 Configuration2.1 Dependencies2.2 WebMvcConfig.java3 jsp view Prerequistes Please read : Java spring &#8211; quickstart Configuration Dependencies If you use maven, add this to your pom.xml : org.webjars webjars-taglib 0.3 org.webjars jquery 3.1.1 WebMvcConfig.java In WebMvcConfig.java, add the ressouce : @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler(&#8220;\/webjars\/**&#8221;).addResourceLocations(&#8220;\/webjars\/&#8221;); } jsp view Import the following taglib: Then [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1547,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1612","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1612","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1612"}],"version-history":[{"count":2,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1612\/revisions"}],"predecessor-version":[{"id":1614,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1612\/revisions\/1614"}],"up":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1547"}],"wp:attachment":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}