VisualBuilder
  Home > Java > Tutorials > Spring and Struts - Hello World example - Spring tutorial
Tell a friend
Link to us
Total Members
      Members: 84648
     
Sitemap Forum Chat
Home
Spring Tutorial Tutorial Home
1 . What is Spring?
2 . What are the main concepts for Spring?
3 . Why use Spring?
4 . Spring architecture
5 . Installing Spring
6 . Where is Spring in our applications?
7 . How to create a bean descriptor XML file?
8 . Spring and Struts
9 . Spring and Struts - Hello World example
10 . Spring data access overview
11 . Spring data access example using Hibernate
12 . Next Steps
 
Java Group Home
Java Discussion (273)
Java Members (27593)
Java Resources
Java Source Code (1095)
Java Articles (5)
Java Blogs
Java Jobs
Java Components (84)
Java Books
Java Websites (126)
Java News (103)
Java Q & A (114)
- Java Ask Question
- Java Questions
- Java Unanswered Questions
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Hibernate Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (436 )
Source Code (3275 )
Articles (11 )
Components (1589 )
News (888 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise


Java spring Tutorial
 Spring and Struts - Hello World example
  << Prev: Spring and Struts Next: Spring data access overview >>

We build a Struts web application using the greeting service through Spring like using in Hello world application above


Design and Code
This example is quite simple. It includes only an Action class,GreetingAction,to use Spring application context to look up the greeting service and request for service. The diagram below shows the sequential interactions between GreetingAction,Spring application context,and GreetingService



a Struts plug-in that is aware of the Spring application context. Add the following code to your struts-config.xml to register the plug-in:

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">


<set-property property="contextConfigLocation" value="/WEB-INF/spring-services.xml"/>


</plug-in>



ContextLoaderPlugIn loads a Spring application context (a WebApplication-
Context,to be specific),using the context configuration files listed (comma separated)in its contextConfigLocation property.


The spring-services.xml declares only bean service with content as in following:



When receive request,GreetingAction will use Spring application context to look up GreetingService,the code below shows that:




How to run
Steps below describe the ways to deploy and run this web application on Tomcat


1. Register GreetingService as a common service on Tomcat by copying greetings.jar file into $CATALINA_HOME/commons/endorsed,figure below is for example:



2. Deploy the web application by copying it into Tomcat web folder:




3. Open web browser and go to the link below:




  << Prev: Spring and Struts Next: Spring data access overview >>
Java Spring Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
LINKS
MSN
Video Surveillance
Exchange Hosting
Gift to Pakistan
 
ADVERTISEMENT
 
PARTNER LIST

More
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising