context:component-scan 分析

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

上一篇:Tickeys -- 找对打字的感觉 (机械键盘音效软件)


下一篇:vb安装过程中 ntvdm.exe[9696]中发生未处理的win32异常