I am trying to import jquery script to my jsp page from maven repository. But it is not working. Please find the details below
My pom.xml:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.11.1</version>
<type>jar</type>
</dependency>
I have this jar in my .m2 folder as well.
My jsp code:(I have tried the following ways which I found in net but dint help)
<SCRIPT src="${pageContext.request.contextPath}/webjars/jquery/1.11.1/jquery.js" type="text/javascript"></SCRIPT> //did not work
<SCRIPT src="webjars/jquery/1.11.1/jquery.js" type="text/javascript"></SCRIPT> // did not work
Could anyone please help me?
If you are using Servlet2 for example, you have to Register WebjarsServlet
in your web.xml
:
<!--Webjars Servlet-->
<servlet>
<servlet-name>WebjarsServlet</servlet-name>
<servlet-class>org.webjars.servlet.WebjarsServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WebjarsServlet</servlet-name>
<url-pattern>/webjars/*</url-pattern>
</servlet-mapping>
Please refer to documentation to config correctly webjars with other frameworks spring-boot... http://www.webjars.org/documentation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.