Spring Framework was first founded by Rod Johnson in his book <Expert One-one-one J2EE Design and Development> and the sample framework in the book was developed to nowadays' Spring Java Framework. It is developed to lessen the complexity of developing applications.
There are a few characteristics of Spring Framework, such as Inversion of Contro, Dependency Injection, Aspect-Oriented Programming, and Model-View-Controller pattern.
Inversion of Control (IoC) is a design principle that allows classes to be loosely coupled and, therefore, easier to test and maintain. Dependency Injection(DI) is a fundamental aspect of the Spring framework, through which the Spring container “injects” objects into other objects or “dependencies”. Aspect-Oriented Programming(AOP) helps break down the program's logic into several distinct parts called concerns.
Configuration
For the configuration on Eclipse, we will download Spring Tool Suit(STS) Program instead of adding a plugin.
Click the link below to download Spring Tools 4 for Eclipse.
If you want to download STS 3.x, click the link below.
Spring Tool Suite 3 · spring-attic/toolsuite-distribution Wiki · GitHub
I will download this.
Download and pin to taskbar.
This is the first screen that you will see once you run the program.
It looks similar to Eclipse, but the difference is when you select a wizard. When you select a wizard. In Spring, you can create Spring projects.
Let's get started with setting encoding.
In Window-Preferences Search "encoding".
In Workspace, CSS Files, HTML Files, JSP Files, you will set the encoding with your language. In my case, I will set as "UTF-8".
Since it is all set, we will make a spring project.
In File - New - Project, create Spring Legacy Project.
Choose the Spring MVC Project.
Insert the domain reversely. Click Finish, and it is all set!
If you can't see the encoding result (In the case of Korean), add this code to the file.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
This figure is how MVC in spring works. Since we now use @annotations, we don't pass to the Handler Mapping.
Client -> Dispatcher Servlet -> Controller-> ModelAndView -> ViewResolver -> View
When you run the project in Spring, web.xml will be read first.
You will see the prefix and suffix in the servlet-context.xml for the configuration.
With this, you don't have to write them when you link the page in the HomeController.java.
In the next post, we will look through the main features of Spring Framework: IoC, DI, and AOP.
'Spring & Spring Boot' 카테고리의 다른 글
Spring) How to start a new Spring Framework Project[2] (0) | 2022.10.14 |
---|---|
Spring) How to start a new Spring Framework Project[1] (0) | 2022.10.11 |
Spring) Spring with MyBatis / Configuration (0) | 2022.10.08 |
Spring) Interceptor (0) | 2022.10.06 |
Spring) Basic Structure and Annotations (0) | 2022.10.05 |