Spring+hibernate+struts

Source: Internet
Author: User

First, Spring

1. Concept:

Container: A container can load objects, instantiate objects, and configure dependencies between objects.

Ioc/di
Ioc:inversion of control (inversion of controls) refers to dependencies between programs that depend on a specific implementation (such as DISKUSB,UUSB) and become dependent on the abstract interface (USB).
Bottom line: dependency abstraction is not concrete .
Di:dependency Injection (Dependency injection) means that the dependencies between programs are injected dynamically by the container, rather than hard-coded implementations.
All the classes in spring are javabean,bean like the pillars of a necklace, and the configuration file is like a line that strings all the beads together.

Aop:aspect oriented programming (aspect-oriented programming) refers to one aspect of a program that is independently designed (such as transactions, logs, permissions, and so on).

2.Spring Introduction
(1) Provide one-stop service for enterprise-level development (integrated hibernate,spring MVC, etc.);
(2) Ioc:spring's core ideas and implementation, most of the functions are based on this;
(3) AOP: Provides three implementations of AOP technology in spring;
(4) Support for persistent claims: encapsulates the operation of JDBC;
Integrated with the popular technical framework (HIBERNATE,JDO,TOPLINK,IBATTS);
(5) Support for the Web tier:
Spring MVC;
Support for other frameworks (Struts,webwork)
(6) Integration of other frameworks and technologies:
RMI and WebService
Ejb
Jms
JavaMail
Timed Tasks and scheduling

3. Use Spring
(1) Add jar package: Spring.jar,commons-logging.jar;
(2) Create configuration file Beans.xml

<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE Beans Public "-//spring//dtd bean//en" "Http://www.springframework.org/dtd/spring-beans.dtd "><Beans>    <BeanID= "HW"class= "Com.lb.action.Test2">        < Propertyname= "Name"value= "Zhangsan" />    </Bean></Beans>

 Public classTest2 {PrivateString name;  PublicString GetName () {returnname; }     Public voidsetName (String name) { This. Name =name; }     Public voidHelloword () {System.out.println (name); }     Public Static voidMain (string[] args) {//(3) obtain the Bean factory;Resource rs =NewClasspathresource ("Beans.xml"); Beanfactory BF=NewXmlbeanfactory (RS); //(4) Get the object. Test2 t2 = (Test2) bf.getbean ("HW"); //(5) calling methodT2.        Helloword (); /*Test2 t2 = new Test2 ();        T2.setname ("zhangsan2"); T2. Helloword ();*/    }}

Spring+hibernate+struts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.