SpringMVC项目找不到Controller

现象:

  新建一个Spring+SpringMVC的项目,配置文件都也检查无误,访问项目根目录下的index.jsp可以访问到,

  但是访问不到action,报错:No mapping found for HTTP request with URI [/test/testPlugAction/init] in DispatcherServlet with name 'dispatcher'

       在配置文件中添加<bean id="testPlugService" class="com.test.easyui.TestPlugServiceImpl"></bean>

  启动报错:org.springframework.beans.factory.CannotLoadBeanClassException:

       Cannot find class [com.test.easyui.TestPlugServiceImpl] for bean with name 'testPlugService' defined in ServletContext resource

        [/WEB-INF/applicationContext.xml];

       nested exception is java.lang.ClassNotFoundException: com.test.easyui.TestPlugServiceImpl找不到类

原因:

  打开项目的工作空间查看编译后的文件位置,如果在WEB-INF下没有classes文件,这就可能是以上报错现象的原因。

解决:

  修改项目编译文件的位置,在eclipse中选中项目右键-properties-Java Build Path-Source中,选择Default output folder把编译后的文件放在WEB-INF的classes文件夹中,

  如果没有classes文件夹可以新建一个,如下图:

  

 

 

posted @ 2017-07-04 15:32  程序媛的爬行之路  阅读(4308)  评论(0编辑  收藏  举报