当前位置: 首页 > news >正文

买完服务器怎么做网站python做的网站源码

买完服务器怎么做网站,python做的网站源码,富顺住房和城乡建设厅网站,国外过期域名查询网站Spring和Spring MVC使用父子容器的设计模式#xff0c;主要是为了实现更好的模块化和隔离#xff0c;提高系统的灵活性和可维护性。具体来说#xff0c;Spring应用通常包含两个层次的容器#xff1a;根容器#xff08;Root WebApplicationContext#xff09;和子容器主要是为了实现更好的模块化和隔离提高系统的灵活性和可维护性。具体来说Spring应用通常包含两个层次的容器根容器Root WebApplicationContext和子容器Child WebApplicationContext。下面是详细解释 1. 根容器Root WebApplicationContext 作用根容器是整个Web应用的基础容器通常用于管理应用的通用Bean如数据源DataSource、事务管理器Transaction Manager、业务服务Service Layer等。配置根容器的配置通常在 web.xml 文件中通过 ContextLoaderListener 加载配置文件通常是 applicationContext.xml。生命周期根容器在整个Web应用的生命周期内一直存在直到应用停止。 2. 子容器Child WebApplicationContext 作用子容器是每个Servlet如 DispatcherServlet的专用容器用于管理与特定Servlet相关的Bean如Controller、视图解析器ViewResolver、拦截器Interceptor等。配置子容器的配置通常在 DispatcherServlet 的配置文件中加载配置文件通常是 servlet-context.xml 或者通过 Configuration 类配置。生命周期子容器的生命周期与对应的Servlet相同当Servlet初始化时创建当Servlet销毁时销毁。 3. 父子容器的关系 继承关系子容器继承了根容器的所有Bean定义但可以覆盖或添加新的Bean定义。隔离性子容器中的Bean不会影响根容器中的Bean从而实现了模块化和隔离。资源共享子容器可以访问根容器中的Bean但根容器不能访问子容器中的Bean。 4. 具体好处 模块化根容器管理通用的、全局的Bean子容器管理特定于Servlet的Bean这种分层设计使得应用结构更加清晰易于维护和扩展。隔离性子容器中的Bean不会影响根容器中的Bean避免了不同模块之间的相互干扰提高了系统的稳定性。资源共享通过继承关系子容器可以共享根容器中的Bean减少了重复配置提高了资源利用率。灵活性可以轻松地添加新的Servlet和对应的子容器而不会影响现有的应用结构。 5. 配置示例 web.xml 配置 web-app xmlnshttp://xmlns.jcp.org/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsdversion3.1!-- 根容器 --context-paramparam-namecontextConfigLocation/param-nameparam-value/WEB-INF/spring/root-context.xml/param-value/context-paramlistenerlistener-classorg.springframework.web.context.ContextLoaderListener/listener-class/listener!-- 子容器 --servletservlet-namedispatcher/servlet-nameservlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-classinit-paramparam-namecontextConfigLocation/param-nameparam-value/WEB-INF/spring/appServlet/servlet-context.xml/param-value/init-paramload-on-startup1/load-on-startup/servletservlet-mappingservlet-namedispatcher/servlet-nameurl-pattern//url-pattern/servlet-mapping /web-app 根容器配置文件root-context.xml beans xmlnshttp://www.springframework.org/schema/beansxmlns:contexthttp://www.springframework.org/schema/contextxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd!-- 数据源 --bean iddataSource classorg.springframework.jdbc.datasource.DriverManagerDataSourceproperty namedriverClassName valuecom.mysql.cj.jdbc.Driver/property nameurl valuejdbc:mysql://localhost:3306/mydb/property nameusername valueroot/property namepassword valuepassword//bean!-- 事务管理器 --bean idtransactionManager classorg.springframework.jdbc.datasource.DataSourceTransactionManagerproperty namedataSource refdataSource//bean!-- 扫描业务服务层组件 --context:component-scan base-packagecom.example.service/ /beans 子容器配置文件servlet-context.xml beans xmlnshttp://www.springframework.org/schema/beansxmlns:contexthttp://www.springframework.org/schema/contextxmlns:mvchttp://www.springframework.org/schema/mvcxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsd!-- 启用Spring MVC注解驱动 --mvc:annotation-driven/!-- 扫描Controller组件 --context:component-scan base-packagecom.example.controller/!-- 配置视图解析器 --bean classorg.springframework.web.servlet.view.InternalResourceViewResolverproperty nameprefix value/WEB-INF/views//property namesuffix value.jsp//bean /beans .总结 根容器管理通用的、全局的Bean如数据源、事务管理器等。子容器管理特定于Servlet的Bean如Controller、视图解析器等。父子容器的关系子容器继承根容器的Bean定义但可以覆盖或添加新的Bean定义实现了模块化和隔离。
http://www.yayakq.cn/news/4865/

相关文章:

  • 南京做机床的公司网站做网站用什么平台
  • 上海外贸网站建设科技成就
  • tp框架做网站无锡专业网站制作
  • 微网站的定义高端h5网站开发
  • 中铁建设集团官方网站知名网站建设公司排名
  • 做板子焊接的网站的公司名字广州网站建设信息科技有限公司
  • c语言和c 哪个做网站好西安微网站
  • 华为快速建站广州门户网站开发
  • 合肥网站建设佳蓝网络mvc网站开发实例
  • 网站建设定义做导航网站把别人的网址链接过来要经过允许吗
  • 网站建设与维护课程设计定制网站建设公司策划书
  • 如何做好网站推广优化phpcms怎么做网站
  • 免费网站建站模板潍坊网站定制模板建站
  • 做外贸需要有自己的网站吗wordpress外贸服装营销型主题
  • 百度网页版浏览器入口官网山东seo推广公司
  • 做网站一般几个人完成wordpress多功能代码
  • 空间站 参考消息WordPress上展示PDF
  • 网站模板切换wordpress无法编辑
  • 网站开发到发布手机医疗网站
  • 网站建设合同报价单 模板下载wap网页编写
  • 西安seo网站设计公司广东省做农业网站公司
  • icp网站备案流程做网站的公司叫什么
  • 顺德区网站设计建设企业网站建设dqcx
  • 出口电商网站建设程序网站建设与管理需要什么软件有哪些
  • 网站建设运维合同一个人能开发app吗
  • 高端网站配色网站申请流程
  • 网站前端开发惠州seo关键词排名
  • 宁波网站设计价格北京seo薪资
  • 上海松一网站建设成都创新互联科技有限公司
  • 北京私人做网站台州网站排名外包