[Spring MVC] What is my Spring MVC controller not working?

以下是上udemy课程里给出的方法,亲测,有效:

THIS IS AN ECLIPSE CACHING BUG

IF YOUR CONTROLLER DOESN'T WORK THEN TRY THE STEPS BELOW

BE SURE TO COME BACK TO THIS ARTICLE

Debug Tip #0: Make sure you are accessing the correct URL

You need to access the correct URL, localhost:8080/spring-mvc-demo/

Note: Do not attempt to run the JSP files directly. This will not work due to MVC.


Debug Tip #1: Make Sure your Package Names is consistent

The Spring configuration file used in the videos expects for your controller to be in the package:

package com.luv2code.springdemo.mvc;

Make sure your controller is this package.


Debug Tip #2: Clear Cache

This is normally a caching issue with Eclipse.

Here are some steps to clear the Eclipse cache and Tomcat cache.

1. In the Server's tab in Eclipse, Stop the Tomcat server

2. Right-click the server and select "Clean..."

3. Right-click the server again and select "Clean Tomcat Work Directory..."

---

4. In the Eclipse, select the top-level menu option, Project > Clean ...

5. Be sure your project is selected and click Ok

6. Restart Eclipse

Retest your application. If you continue to have problems try Debug Tip #2


Debug Tip #3: Import the Project in  a new workspace

1. Copy your project to a new directory on your computer like, c:\foobar

2. In Eclipse, open a new workspace: Create a new workspace in Eclipse: File > Switch Workspace > Other ... > give any name

3. In Eclipse, import the project 

3a. Use File > Import > General > Existing Projects into Workspace

3b. Browse to directory: c:\foobar

4. In your new workspace, add a reference to the Tomcat server

5. Test your app in the new workspace

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值