|
Eclipse IDE Example |
|
Subject: Eclipse IDE Example
Author: WebSpider
In response to: MVC -- Model
Posted on: 10/07/2019 06:41:42 AM
Prerequisites
STS 3.0 Tomcat 8.5
On Eclipse IDE File > New > Project ... > Spring > Spring Legacy Project > Next Type in Project Name: HelloWorldSpringMVC Select Templates > Spring MVC Project Specify the package name: com.example.myapp
Note: myapp will be web context name -- http://localhost:8080/myapp/
>
> On 11/23/2017 02:38:12 AM WebSpider wrote:
Controller method's arguments: Request or response objects: ServletRequest, HttpServletRequest Session object: HttpSession org.springframework.web.context.request.WebRequest java.util.Locale java.io.InputStream / java.io.Reader java.io.OutputStream / java.io.Writer java.security.Principal @PathVariable annotated parameters for access to URI template variables @RequestParam annotated parameters for access to specific Servlet request parameters @RequestHeader annotated parameters for access to specific Servlet request HTTP headers @RequestBody annotated parameters for access to the HTTP request body java.util.Map / org.springframework.ui.Model / org.springframework.ui.ModelMap org.springframework.validation.Errors / org.springframework.validation.BindingResult validation results for a preceding command org.springframework.web.bind.support.SessionStatus status handle for marking form processing as complete, which triggers the cleanup of session attributes that have been indicated by the @SessionAttributes annotation at the handler type level.
Controller method's return types: ModelAndView, Model, Map, View String void -- if the method handles the response itself (by writing the response content directly, declaring an argument of type ServletResponse / HttpServletResponse for that purpose) or if the view name is supposed to be implicitly determined through a RequestToViewNameTranslator (not declaring a response argument in the handler method signature). HttpEntity<?> or ResponseEntity<?> -- to provide access to the Servlet reponse HTTP headers and contents Any other return type is considered to be a single model attribute to be exposed to the view, using the attribute name specified through @ModelAttribute at the method level
References:
|
|
|
|