zoukankan      html  css  js  c++  java
  • context:componentscan 分析

    <context:component-scan>

    Web.xml中

    <servlet>

            <servlet-name>springMVC</servlet-name>

            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

            <init-param>

                <param-name>contextConfigLocation</param-name>

                <param-value>classpath:springMVC.xml</param-value>

            </init-param>

            <load-on-startup>1</load-on-startup>

    </servlet>

    如下配置

    <context:component-scan base-package="com.xt.web.controller" />

    <context:component-scan base-package="com.xt" /> //暂时有错

    springMVC.xml中需要能扫描到Controller.

    否则出现:

    org.springframework.web.servlet.PageNotFound noHandlerFound

    警告: No mapping found for HTTP request with URI [/traffic/w] in DispatcherServlet with name 'springMVC'。

    1.Web.xml中

    <context-param>

            <param-name>contextConfigLocation</param-name>

            <param-value>classpath:spring-hibernate.xml</param-value>

    </context-param>

    <listener>

        <listener-class>org.springframework.web.context.ContextLoaderListener

        </listener-class>

    </listener>

    spring-hibernate.xml文件中配置serivce,dao等spring要素。

    <context:component-scan base-package="com.xt.domain" />

    //路径需要到dao,service等javabean的目录的上级目录.

  • 相关阅读:
    JDK7集合框架源码阅读(四) LinkedHashMap
    JDK7集合框架源码阅读(三) HashMap
    JDK7集合框架源码阅读(二) LinkedList
    在django中解决跨域AJAX
    Python基础之文件操作
    Python基础之深浅copy
    Python基础之集合set
    Python基础之range()
    Python基础之enumerate枚举
    Python基础之for循环
  • 原文地址:https://www.cnblogs.com/myibm/p/5875068.html
Copyright © 2011-2022 走看看