Wednesday 11 December 2013

Spring 3 annotation based rest example



Here I would like to show a small example on how to create a sample spring bases Rest Web services.


Project Structure:

Below is the basic project structure.



Dependencies (pom.xml):

Below are the dependencies required for this project. we can add more based on the requirement.




















View Resolver Configuration:


         <bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>



Controller and util Class:

The controller class handling 2 different type of responses. The method printProjectjson() will return a Json response.





Jsp View:















Browser View:



















Download the source code
SpringRest.zip


Thats the End.....

No comments:

Post a Comment