go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  MVC -- Model
 
Subject: MVC -- Model
Author: WebSpider
In response to: MVC -- View
Posted on: 11/23/2017 02:38:12 AM


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


     

    > On 11/23/2017 02:36:50 AM WebSpider wrote:


    home.jsp
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ page session="false" %>
    <html>
        <head>
    	<title>Home</title>
        </head>
        <body>
            <h1>Hello world!</h1>
    
            <P>The time on the server is ${serverTime}.</P>
        </body>
    </html>
    





    References:

  •  


     
    Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
     
    Get your own forum today. It's easy and free.