Cannot find class for bean with name '/hello' defined in ServletContext resource

Cannot find class for bean with name '/hello' defined in ServletContext resource [/WEB-INF/chapter2-servlet.xml]

今天第一天使用Spring MVC按照pdf上的例子来做第一个"Hello World",结果就报错了。

我用的是eclipse来做的。

  1. 首先新建一个web项目,项目截图如图所示,注意观察一下WEB-INF下面是没有"classes"文件夹的。

    Cannot find class for bean with name '/hello' defined in ServletContext resource
  2. 然后右键一下看看build path,然后我好想明白了点什么,编译之后的classes文件夹根本就没有放到WEB-INF目录下,当然会找不到类了。

    Cannot find class for bean with name '/hello' defined in ServletContext resource
  3. 后来直接把build path下的classes文件直接复制到了WEB-INF目录下,然后重启tomcat,我的hello, world就这样出来了。

    Cannot find class for bean with name '/hello' defined in ServletContext resource

希望能报这个错误给大家拿来参考下!

上一篇:解析xml文件的几种技术


下一篇:Linux tomcat 去除项目名端口号直接用ip或者域名访问网站