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文件夹可以新建一个,如下图:

  

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM