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的目录的上级目录.

  • 相关阅读:
    Ubuntu12.04配置永久静态ip地址
    linux shell 命令获取字符串/文件的MD5值
    设置VMware中Kali 共享文件夹
    tomcat的一些优化及报错
    用Toad for Oracle创建数据库表空间和用户
    linux远程Windows服务器
    linux查询及添加用户
    AJAX
    Cookie和Session
    Django-中间件
  • 原文地址:https://www.cnblogs.com/myibm/p/5875068.html
Copyright © 2011-2022 走看看