Sunday, June 5, 2016

J2EE - Giới thiệu tổng quan về Framework Struts 2

- Đầu tiên mình xin nói qua một chút khái niệm cũng như đặc điểm của một framework :
     - Framework là một tập hợp của các interface và các class giúp phát triển một ứng dụng.
     - Một framework cung cấp cách phương thức sử dụng ở nhiều trường hợp khác nhau.
     - Vai trò của một framework, framework cung cấp sẵn các công cụ, các phương thức cho một công việc nào đó cụ thể.
     - Đặc điểm của một framework :
           - Dễ dàng cho việc nâng cấp và bảo trì.
           - Có khả năng mở rộng và dẽ sử dụng.
           - Cho phép tái sử dụng code.

- Tiếp theo mình sẽ giới thiệu struts 2:
      - Struts 2 : là một open resource được phát triển với Craig McClanahan và được hỗ trợ The Apache Software Foundation.
       - Struts 2 : là một framework theo mô hình MVC. Dựa trên Struts 1 và là cải thiện của struts 1. Struts 2 việc định nghĩa các thành phần trở nên đơn gian và sáng sủa hơn.
       - Mô hình làm việc của Struts 2 :


     - Trong struts 2 là chỉ bao gồm 1 controller và controller này có thể chứa các controller khác.
     - Sau khi nhận request của người dùng, controller sẽ xác định xem sẽ gọi đến Action nào.Sau đó dữ liệu truyền vào model.
     - Sau đó Action sẽ chuyển hướng đến View và View sẽ lấy dữ liệu từ model và trả về response cho người dùng.
     - Mô hình chi tiết hơn :

          - Khi người dùng có 1 request lên server. Thì request sẽ chuyển đến ActionMapper và sau đó nó sẽ đi qua các filter.
           - Sau đó nó sẽ đọc file struts.xml, tùy thuộc vào config trong file struts.xml. ActionProxy sẽ chuyển đến Action tương ứng. Trước khi gọi Action thì nó sẽ các gọi các interceptor nếu có. Sau đó nó gọi đến Action thật sự và nó trả về resuilt.
          - Sau khi có Resuilt nó sẽ định hướng đến View, sau đó nó tiếp tục đi qua các interceptor và trả về Response cho người dùng.

7 comments:

  1. I like to read your posts very much.They contain pieces of advice. I hope I will add more posts.I want to enjoy more and more about your writing. I wish you best things in life.
    currency converter app currency-converter-box-free-online

    ReplyDelete
  2. Nice post. I study one thing tougher on completely different blogs everyday. I am trustworthy identical best work from you when you need it at the same time
    https://bit.ly/2QslLr4
    https://autoketing.com/project/sale-pop-master, autoketing app

    ReplyDelete
  3. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!
    gaigoionline, clip gai goi, gai goi hn, gai bao, gai goi hcm

    ReplyDelete
  4. You actually make it appear really easy with your presentation however I in finding this topic to be really one thing which I think I would by no means understand. I decided to add your blog to my bookmarks so I can return to it at a later date.
    abcya3 2 player motox3m3 games online gogy 2 player

    ReplyDelete
  5. Topic of web journal is great there is just about everything to peruse. I'll make sure to bookmark it and return to peruse a greater amount of your helpful information.
    best gameBlocky Craft Police Squad game Mommy Elsa Baby Caring best game Tomb Runner

    ReplyDelete
  6. Thanks for the auspicious writeup. When I have spare time, I often read your posts.When I need a piece of advice, I will find your posts and read them.
    Kick The Buddy game Def Island Real Flight Simulator best game for free

    ReplyDelete
  7. A debt of gratitude is in order for setting aside an ideal opportunity to examine this, I feel emphatically about it and affection adapting more on this theme. On the off chance that conceivable, as you pick up skill, would you psyche overhauling your online journal with more data? It is to a great degree supportive for me.
    2player best free online games
    friv Games to play
    io jogos for school

    ReplyDelete