Wednesday, July 23, 2014

Integration of DWR using Spring MVC

DWR is a Easy Ajax for Java. To know more click here.

In this article we will see sample codes for integration of DWR with spring MVC

Step 1 - Create a web project in eclipse.

Step 2 - Add below Spring libraries

  • Spring Core libraries
  • Spring Web libraries
  • Spring AOP libraries

Step 3 - Add dwr.jar
Download appropriate version of dwr.jar and add it in your application classpath. For example DWR 3 requires Spring version 2.5 or greater.

Step 4 - Create dependent files

web.xml
Create spring DispatcherServlet and map URL pattern as shown below

javaxp-servlet.xml
If you are using Spring MVC you must declare dwr controller and url mapping i.e. SimpleUrlHandlerMapping as shown below

DWRService.java

index.jsp

Step 5 - Deploy the project in tomcat (or any other web server) and check the output