亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從不使用帶有 @RequestMapping 的類

從不使用帶有 @RequestMapping 的類

守候你守候我 2021-12-18 15:16:03
我正在嘗試使用此視頻示例(小心,俄語語音)編寫 REST 服務器。在示例中,當講師在控制器類上方編寫 @RequestMapping 時,類將被使用。但在我的情況下,控制器類“從未使用過”,當我用我的控制器啟動 tomcat 服務器并進入頁面http://localhost:8000/app/remind/get 時,我收到這個錯誤:沒有映射 GET /應用程序/提醒/獲取這是我的控制器代碼:@Controller@RequestMapping("/reminder")public class ReminderController {    @RequestMapping(value = "/get", method = RequestMethod.GET)    @ResponseBody    public String getReminder(){        return "my reminder";    }}這是我的 WebConfig.java@Configuration @EnableWebMvc@ComponentScan("com.fillooow.remindme.server")public class WebConfig extends WebMvcConfigurerAdapter {}那么,你能解釋一下,為什么我的課程“從未使用過”,我錯過了什么?編輯 我的問題是配置文件中的錯誤上下文(“/”而不是“/app”)
查看完整描述

2 回答

?
富國滬深

TA貢獻1790條經驗 獲得超9個贊

建議:試試@GetMapping; 確保您使用的是正確的 URL:


@Controller

@RequestMapping("/reminder")

public class ReminderController {


    @GetMapping(value = "/get")

    @ResponseBody

    public String getReminder(){

        return "my reminder";

    }

}

... 和 ...


http://localhost:8000/app/reminder/get

另外:我不確定您的上下文根(“應用程序”)或您的端口(“8000”與“8080”)。


可能的選擇:


http://localhost:8080/reminder/get

附加建議:啟用調試


logging.level.org.springframework=DEBUG


查看完整回答
反對 回復 2021-12-18
?
慕運維8079593

TA貢獻1876條經驗 獲得超5個贊

嘗試如下端點

 http://localhost:8000/reminder/get


查看完整回答
反對 回復 2021-12-18
  • 2 回答
  • 0 關注
  • 207 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號