zoukankan      html  css  js  c++  java
  • The flow of MVC in Spring Part I Dispatcher and Controller

    From the example on spring official site, I conclude the flow of Spring's MVC.

    1. Request --> org.springframework.web.servlet.DispatcherServlet --> parse [ServletName]-servlet.xml --> dispatch to Controller
        The “Request” is the “url-patten” mapped in web.xml of web application.
        [ServletName] is the name DispatcherServlet mapped (you can also extend it).

    2.  Create your own Controller “MyController“ --> implement Interface org.springframework.mvc.Controller  --> write code of  controlling in method handleRequest() which inherited from “Controller” -->  return the created model and view obejcts of org.springframework.mvc.ModelAndView --> the framework will render it automatically
        The constructor of ModelAndView takes 1 or 3 parameter(s). 

        For 3 parameters, first one is the view path (The truth path or resolved path. The resolved path is resolved by org.springframework.web.sevrlet.view.InternalResourceViewResolver. I will explain it when I post the next time.). 
        The second one is the model object's given name, it's String. This name is NOT the object's variant-name. This name will be used in jsp. You can look it as an alias.
        The third one is the model object ( just the variant you will pass to jsp view ).

    3. Ok, Use the returned model object in jsp.

    I am an beginner of Java, so i can not conclude if the flow is the common MVC flow.

    to be continue ...

  • 相关阅读:
    javascript中错误使用var造成undefined
    眼下流行的几种排课算法的介绍
    UVA 11212 IDA*
    Delphi 2007体验!
    全局钩子具体解释
    客户信用控制请求
    【2012.1.24更新】不要再在网上搜索eclipse的汉化包了!
    Android URI简单介绍
    数据结构
    关于 Head First SQL 中文版
  • 原文地址:https://www.cnblogs.com/Samuel/p/28038.html
Copyright © 2011-2022 走看看