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