zoukankan      html  css  js  c++  java
  • Spring集成web

    1导入坐标

        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>5.0.5.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>5.0.5.RELEASE</version>
            </dependency>

    2配置监听器 在web.xml中

        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext.xml</param-value>
        </context-param> 
    
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

    3使用WebApplicationContext获取上下文

    public class UserServlet extends HttpServlet {
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            ServletContext servletContext = this.getServletContext();
            ApplicationContext webapp = WebApplicationContextUtils.getWebApplicationContext(servletContext);
            UserService userService=webapp.getBean(UserService.class);
            userService.save();
    
        }
    }
  • 相关阅读:
    7.逻辑回归实践
    6.逻辑回归
    5.线性回归算法
    4.K均值算法应用
    3.k均值的算法
    2.机器学习相关数据基础
    1.机器学习概论
    作业十五——语法制导的语义翻译
    第03组 Beta冲刺(3/4)
    第03组 Beta冲刺(2/4)
  • 原文地址:https://www.cnblogs.com/ziwang520/p/15798310.html
Copyright © 2011-2022 走看看