Tag: Spring-REST-Template

Hi all in the previous post i have shown you how to create a mavenized Spring MVC Project with full configuration in that the Spring controller is returning a JSON String, now this is the string we want to collect in android client by calling it using Spring-Rest-Template.

The Jar files required for this application are
android-support-v4.jar
spring-android-auth-1.0.0.RELEASE.jar
spring-android-core-1.0.0.RELEASE.jar
spring-android-rest-template-1.0.0.RELEASE.jar

For JSON Support add the following jar files
jackson-core-asl-1.9.11.jar
jackson-mapper-asl-1.9.11.jar

Hi All, This time i had very tough time to show my proof of concept to one of my colleague regarding java Spring mvc and Android. the requirement is quite direct we have to create a Spring MVC project and deploy it to server and call the spring controller using Android Activity. Thanks to spring it has released Spring-rest-template api using which we can call the business logic that is deployed in the server as spring controller. so here is my example code to you how to call spring mvc using Android Rest Client

in this part i will be explaining u how to create a spring mvc project using maven dependencies.

Note: dont code network related logic in the main thread of android activity it will lead to android.os.NetworkOnMainThreadException

now that we have completed our configuration its time for us to write the model classes and business logic for handling requests from android client and return responce. Here we use JSON for communication layer. notice that you put the code in appropriate packages.
source code for controller

now its time to test the application open cmd and navigate to the project folder and issue “mvn clean install package”
without quotes it will download all jar files needed by your application and it builds the war file(bueauty of maven)
now your project is ready for deployment issue the command “mvn tomcat:run” without quotes your tomcats starts and your war will be deployed now your Spring MVC project is up and running lets see how to code Android REST client and communicate with Spring Web App in Part-II.