In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you an analysis of how to carry out Spring MVC. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
MVC is already a very important part of modern Web development. Here are some tips on how to use Spring MVC.
The previous project is relatively simple, mostly with JSP, Servlet + JDBC directly, last year began to try to use Struts (Spring MVC) + Spring+Hibernate in the project, strictly according to the hierarchical concept to drive project development, because the project requirements have been constantly changing, functions continue to expand, enhance, technical construction has also changed several times to have a stable application, experience a lot of feelings, this time first make some personal summary of the Spring MVC layer.
MVC as the core link of WEB project development, just like the decomposition of three words, C (controller) separates V (view, user client) and M (module, business) into MVC. Instead of discussing whether to apply MVC or more principles of MVC, it will evolve from applying SSH to Spring MVC + Spring+Hibernate in practice.
First, let's see how Struts combines with Spring to handle a simple request response code. The foreground can be set to call with AJAX:
1. Add to the struts-config.xml file
two。 Add to the applicationContext.xml file
3.cn.base.GetPersonListAction implementation request response code
You can see that there are so many steps required for a request, and there are many such request responses under a project, which will bring a lot of trouble to the configuration file management.
After the in-depth application of Spring, Spring itself provides URL request control, and its natural support allows us to avoid the need for applicationContext.xml to declare URL request Bean again, that is, to reduce the declaration URL of Struts, so as to reduce some tedious configuration. But only a little less, it will also face the problem of managing configuration files.
Spring annotations will make our work a little easier, and annotations based on the principle of reflection mechanism are designed to solve a large number of configuration problems. Please take a look at the code that handles a simple request response.
@ Controller-declare the controller @ RequestMapping ("/ person.do")-declare that URL public class PersonControl extends BaseController {@ Autowired-the business interface injects private personServices personServices; / * to get the personnel list * @ param request * @ param response * @ throws Exception * / @ RequestMapping (params = "method=geList")-that is, to process / person.do? Method=geList method public void getnodeList (HttpServletRequest request, HttpServletResponse response) throws Exception {/ / process request / / process response}}
As you can see, adding comments to the code can save the work of multiple configuration files we mentioned above and make it easy for MVC to handle request responses.
With a simple profile declaration, you can easily handle all the request control work of the project.
This is the end of the personal summary of Spring MVC.
The above is the editor for you to share how to analyze Spring MVC, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.