Share on Google+Share on Google+

Spring MVC JQuery Integration

Advertisement
In this section, you will learn about Spring MVC JQuery Integration by deployment descriptor.

Spring MVC JQuery Integration

In this section, you will learn about Spring MVC JQuery Integration by deployment descriptor.

PROBLEM

When you are including your js file in your view JSP file or adding any jQuery plug in using relative path, it doesn't include it. If you views the source code of that page and click on it, it will show you resource not found type error because it didn't locate the .js file

SOLUTION

You can eliminate the above problem by adding .js URL pattern mapping in deployment descriptor(web.xml) as follows :

<servlet>
<servlet-name>statCont</servlet-name>

<servlet-class>
	org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>
<servlet-name>statCont</servlet-name>

<url-pattern>*.js</url-pattern>
</servlet-mapping>

<servlet-name> can be any name you want.

Advertisements

Advertisement

Posted on: June 1, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.