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

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

Spring MVC 休息控制器未調用

Spring MVC 休息控制器未調用

臨摹微笑 2023-11-10 15:40:33
我正在開發一個彈簧支架控制器。但是,當我嘗試訪問 url ( http://localhost:8080/customer-crm/api/customer ) 時,它不起作用并給出 404 not find 。但對于根“/”,它工作正常并給出index.jsp頁面這是AppConfiguration.class:package com.customer.crm.configuration;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.ViewResolver;import org.springframework.web.servlet.config.annotation.EnableWebMvc;import org.springframework.web.servlet.view.InternalResourceViewResolver;import org.springframework.web.servlet.view.JstlView;@Configuration@EnableWebMvc@ComponentScan(basePackages = "com.customer.crm")public class AppConfiguration {    @Bean    public ViewResolver viewResolver() {        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();        viewResolver.setViewClass(JstlView.class);        viewResolver.setPrefix("/WEB-INF/views/");        viewResolver.setSuffix(".jsp");        return viewResolver;    }}這是Index.class控制器:package com.customer.crm.rest;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RestController;import com.customer.crm.entity.Customer;@RestController@RequestMapping("/api")public class Index {    @RequestMapping(value = "/customer", method = RequestMethod.GET)    public Customer getIndex() {        System.out.println("executing in index controller");        Customer customer = new Customer("Mike", "John", "[email protected]");        return customer;    }甚至連消息也getIndex()沒有打印出來。我嘗試清理項目并清理 tomcat 目錄,但沒有任何改變。誰能告訴我問題出在哪里?
查看完整描述

1 回答

?
千萬里不及你

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

哦伙計們,我解決了。這是該文件的拼寫錯誤application.properties。它被命名為“application.properities”。抱歉占用您的時間,謝謝!



查看完整回答
反對 回復 2023-11-10
  • 1 回答
  • 0 關注
  • 141 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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