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 ...

  • 相关阅读:
    关于bool operator() 几种变种实现的整理
    C# 访问修饰符
    C# 运算符
    c# 集合、存储及排序、迭代
    【并查集】tree
    【最大流】【POJ1149】PIGS
    【拆边最小费用流】【Asia Harbin 2010/2011】【Transportation】
    【DP】【GG选题】
    【DP】【芝麻开门】
    【搜索】【2012 Dhaka Regional】E Poker End Games
  • 原文地址:https://www.cnblogs.com/Samuel/p/28038.html
Copyright © 2011-2022 走看看