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

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

相关文章:

  • 2021-10-25
  • 2021-09-22
  • 2021-06-15
  • 2021-06-30
  • 2021-05-30
  • 2021-09-23
  • 2022-01-20
  • 2021-05-22
猜你喜欢
  • 2021-12-27
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案