I read Web MVC framework - Reference Guide.
This article shows some basic ideas in Spring Web MVC.
🐞 Key Design Principle
A key design principle in Spring Web MVC and in Spring in general is
the “Open for extension, closed for modification” principle.
🎉 Features
- Clear separation of roles
- Powerful and strightforward configuration of both framework and application class as JavaBeans
- Adaptability, non-insrusiveness, and flexibility
- Reusable business code, no need for duplication
- Customizable binding and validation
- Customizable handler mappning and view resolution
- Flexible model transfer
- Customizable locale, time zone and theme resolution
- A simple yet powerful JSP tag library, Spring tab library
- A JSP form tag library
- Beans whose lifecycle is scoped to the current HTTP request orf HTTP session
🚕 Front Controller Pattern
Spring MVC Architecture use “Front Controller Pattern”.
Front Controller do the following processes:
- Receive client request
- Convert request data to Java Object
- Run input check(Bean Validation)
- Call Handler(Controller)
- Find View
- Reply response data to client
- Handle exception
🚜 Arguments for Handler
- Model : Interface having data to send to transition destination
- RedirectAttributes : Interface having data to redirect destination
- JavaBeans like Form Class : JavaBeans class having request parameter
- BuindingResult : Interface having validation result by form input
- MultipartFile : Interface having file info which was uploaded by using multipart-request
- HttpEntity> Interface having request header and request body
- java.util.Locale : Client Locale
- java.util.TimeZone / java.time.ZoneId : Client time zone when you use Java 8
- java.security.Principal : Inteface having authorized client user info
- UriComponetsBuilder : Interface to build URI
🎳 RequetMapping
The some attributes in @RequestMapping
are as follows:
- value: Set request path or path pattern
- path: Alias of value attribute
- method: HTTP Method (GET, POST, PUT) for mapping rule
- params: Request Parameter for mapping rule
- headers: Request header for mapping rule
- consumes: Context-Type Header in request for mapping rule
- produces: Accept Header in reqest for mapping rule
- name: Original name for the mapping
🐡 Argument Annotation
Request Data
- @PathValiable : Get value of path valiable in URL
- @MatrixVariable : Get matrix value in URL
- @RequestParam : Get value of request header
- @RequestHeader : Get value of request header
- @CookieValue : Get value in cookie
- @RequestBody : Get content of request body
Not Request Data
- @ModelAttribute : Get object of model as argment
- @Value : Ge value by replacing from place holder like (${})
👽 Get Request Data
- @PathVariable : Get path variable
- @RequestParam : Get value of specified request parameter
- @RequestHeader : Get value of specified request header
- @CookieValue: Get value of specified request cookie
"detail", method = RequestMethod.Get) (path = |
🐯 Terms
JavaBeans
JavaBeans are classes that encapsulate many objects into a sible object.
The name “Bean” was given to encompass this standard, which aims to create
resusable software components for Java.
JavaBeans - Wikipedia, the free encyclopedia
Nullary
The number of arguments or operands taken by a function or operator.
instantiate
To represent(an abstraction) by a concreate instance
🖥 Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!