SpringMVC (Spring MVC)

Source: Internet
Author: User

SpringMVC (Spring MVC)

Let's first look at the SpringMVC diagram.

Create a project, create a config resource folder, and configure the file

Web. xml:

 

   
    
      
   
    
Index. jsp
     
    
    
     
   
    
SpringMVC
     
   
    
Org. springframework. web. servlet. DispatcherServlet
    
    
    
    
     
ContextConfigLocation
     
    
     
Classpath: applicationContext-mvc.xml
     
     
      
    
   
    
SpringMVC
     
     
   
    
*. Action
     
   
 

 

 

Application-mvc.xml, Which is configuring processor ing, processor adapter, view parser, Handler

 

 
  
  
  
  
  
  
  
  
  
  
  
  
   
   
   
  
  
  
 

 

 

 

Aopalliance. jar: this package is an API package of the AOP alliance, which contains interfaces for aspect orientation. Usually other frameworks such as Spring that have the Dynamic Weaving function depend on this jar

Spring-core.jar: this jar file contains the basic core tool class of the Spring framework. Other components of Spring must use the class in this package, which is the basic core of other components.

Of course, you can also use these tool classes in your application system.
The external dependency is Commons Logging (Log4J ).

Spring-beans.jar: this jar file is used by all applications and contains access to the configuration file, creation and management of beans, and Inversion of Control/

Dependency Injection (IoC/DI) operations related to all classes. If the application only requires basic IoC/DI support, introduce spring-core.jar and spring-beans.jar files

You can.

Spring-aop.jar: this jar package contains class and source code-level metadata support required when Spring's AOP features are used in applications. Use Spring features based on AOP, such as declaration

The jar package must also be included in the application.
The external dependency is spring-core, (spring-beans, AOP Alliance, CGLIB, Commons Attributes ).

Spring-context.jar: this jar file provides a lot of extensions for the Spring core. You can find all the classes required to use the Spring ApplicationContext feature, JDNI

All required classes, instrumentation components, and Validation-related classes.
The external dependency is spring-beans (spring-aop ).

Spring-context-support: Spring-context extension support for MVC

Spring-web.jar
This jar file contains the core classes required to use the Spring framework during Web Application development, including the classes for automatically loading the Web Application Context feature, Struts and JSF

Integration class, file upload support class, Filter class, and a large number of tool auxiliary classes.
The external dependency is spring-context, Servlet API, (jsp api, JSTL, Commons FileUpload, COS ).

Spring-webmvc.jar
This jar file contains all classes related to the Spring MVC framework. Includes the framework Servlets, Web MVC Framework, controller and view support. Of course, if your application uses

The MVC Framework does not require any classes in the JAR file.
The external dependency is spring-web, (spring-support, Tiles, iText, POI ).

Spring-aspects.jar
Provides support for AspectJ so that you can easily integrate aspect-oriented functions into the IDE, such as Eclipse AJDT.
External Dependency.

Spring-jdbc.jar
This jar file contains all classes that encapsulate Spring's JDBC data access.
The external dependency is spring-beans and spring-dao.

Spring-test.jar
Simple encapsulation of Junit and other testing frameworks

Spring-tx.jar
Jar for Spring tx Transaction Processing

Spring-expression.jar
Spring Expression Language


Spring package dependency description:
1) spring-core.jar needs commons-collections.jar, spring-core.jar is the basic of the following other.

2) spring-beans.jar for spring-core.jar, cglib-nodep-2.1_3.jar

Spring-aop.jar, spring-core.jar, spring-beans.jar, aopalliance. jar

4) spring-context.jar, spring-core.jar, spring-beans.jar, spring-aop.jar, aopalliance. jar

5) spring-dao.jar spring-core.jar, spring-beans.jar, spring-aop.jar, spring-context.jar

6) spring-jdbc.jar spring-core.jar, spring-beans.jar, spring-dao.jar

7) spring-web.jar spring-core.jar, spring-beans.jar, spring-context.jar

Spring-webmvc.jar/spring-core.jar/spring-beans.jar/spring-context.jar

Spring-hibernate.jar, spring-core.jar, spring-beans.jar, spring-aop.jar, spring-

Orm. jar, spring-web.jar,
Spring-webmvc.jar

Spring-orm.jar, spring-core.jar, spring-beans.jar, spring-aop.jar, spring-dao.jar

Spring-webmvc.jar

11) spring-remoting.jar spring-core.jar, spring-beans.jar, spring-aop.jar, spring-dao.jar, spring-context.jar,

Spring-web.jar, spring-webmvc.jar

12) spring-support.jar spring-core.jar, spring-beans.jar, spring-aop.jar, spring-dao.jar, spring-context.jar,

Spring-jdbc.jar

13) spring-mock.jar spring-core.jar, spring-beans.jar, spring-dao.jar, spring-context.jar

 

Control class HelloAction:

Package com. mvc. action; import javax. servlet. http. httpServletRequest; import javax. servlet. http. httpServletResponse; import org. springframework. web. servlet. modelAndView; // @ Controller: Mark this class as a Handler processor public class HelloAction implements org. springframework. web. servlet. mvc. controller {public ModelAndView handleRequest (HttpServletRequest request, HttpServletResponse response) throws Exception {// a message is prompted on the page Message String message = "hello world! "; // Display information on the page through the request object // request. setAttribute ("message", message); ModelAndView modelAndView = new ModelAndView (); // request. setAttribute (): uploads data to the page to display // model data modelAndView. addObject ("message", message); // sets the view modelAndView. setViewName ("hello"); return modelAndView ;}}

Hello. jsp:

 

<%@ import="java.util.*" language="java" page="" pageencoding="ISO-8859-1"><% basepath="request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";" path="request.getContextPath();" string="">My JSP 'hello.jsp' starting page
 
 
 
 
 
   ${message}
 
 

<% @ Import = "java. util. * "language =" java "page =" "pageencoding =" ISO-8859-1 "> <% basepath =" request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; "path =" request. getContextPath (); "string =" "> enter http: // localhost: 8080/SpringMVCDemo/hello. action is displayed.

 

 

Zookeeper

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.