This is a super Hello World Project ;-)
It consists:
Section 1 Spring:
- Mult-Way Spring Bean/IoC Configations
- Spring AOP
- Spring Jdbc
- Spring-Hibernate
- Spring-Struts2
Section 2 Spring-MVC:
-
@RequestMapping(value, method, headers), @RequestParam, @PathVariable, @ResponseBody ......
-
SpringMVC Handler Method: POJO, Servlet API, ModelAndView, Map, Model, @SessionAttribute, @ModelAttribute, forward:, redirect:
-
REST CRUD
-
Spring Form: Form Input -> Java Object(modelAttribute, path, cssClass. cssErrorClass,htmlEscape, form:input,radiobutton, errors, select ......)
-
DataBinding - Formatting - Validating:
ServletRequest -> WebDataBinderFactory -> DataBinder -> ConversionService -> Validator -> BindingResult
Bind + Convert + Validate and Result.
a. Convert:
CustomConversionService: Coverter<S,T>, ConverterFactory, GenericConverter
@InitBinder method to init WebDataBinder
b. Format:
FormattingConversionService e.g. @DateTimeFormat(pattern, iso, style), @NumberFormat(Style.CURRENCY) apply to Entity Classes
c. Validate:
JSR 303 + Hibernate Validator + Spring LocalValidatorFactoryBean + @valid (@argument + BindingResult or Errors).
JSP can also access thru form:error path="???"
Validation Annotation applies to Entity Classes
Validation Msg Localization with i18n
-
JSON + HttpMessageConverter @RequestBody + @ResponseBody on Mehotd or HttpEntity + ResponseEntity on method arug and return DataType
-
Localization with i18n; LocalResolver, CookieLocaleResolver, SessionLocaleResolver, LocalChangeInterceptor
-
File Upload: MultipartResolver implements CommonsMultipartResolver. By default SpringMVC would not init MultipartResolver, so add CommonsFileUpload + CommonsIO dependencies and config multipartResolver Bean
-
Interceptor: preHandle, postHandle, and afterCompletion when pre returns TRUE: pre -> handler -> post -> render -> after when pre returns FALSE: pre Also, the mult-interceptors flow with some pre returns false ;-)
-
Exception: HandlerExceptionResolver a. ExceptionHandlerExceptionResolver: @ExceptionHandler (order? the closer Class to the Exception Class). If cannot find any matching method in the handler class, app will look for a method has @ExceptionHandler of a @ControllerAdvise Class b. @ResponseStatus: apply to CustomException Class c. DefaultFhandlerExceptionResolver d. SimpleMappingExceptionResolver
-
Reconfig Spring + Spring MVC App: Spring IoC Bean: Parent vs Spring MVC: Child Spring cannot access Spring MVC Spring MVC can access Spring e.g. Spring IoC Bean includes everything but @Controller and Spring MVC only includes @Controller
-
Spring MVC vs Struts2 Spring MVC: Pro: Servlet - methods (a bit faster), JSR303, AJAX Struts2: Filter - classes Pro: OGNL better Font-end