我正在開發一個彈簧支架控制器。但是,當我嘗試訪問 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”。抱歉占用您的時間,謝謝!
添加回答
舉報
0/150
提交
取消