我正在開發(fā)一個(gè)彈簧支架控制器。但是,當(dāng)我嘗試訪問 url ( http://localhost:8080/customer-crm/api/customer ) 時(shí),它不起作用并給出 404 not find 。但對(duì)于根“/”,它工作正常并給出index.jsp頁(yè)面這是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", "mike.john@gmail.com"); return customer; }甚至連消息也getIndex()沒有打印出來。我嘗試清理項(xiàng)目并清理 tomcat 目錄,但沒有任何改變。誰(shuí)能告訴我問題出在哪里?
1 回答

千萬(wàn)里不及你
TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超9個(gè)贊
哦伙計(jì)們,我解決了。這是該文件的拼寫錯(cuò)誤application.properties
。它被命名為“application.properities”。抱歉占用您的時(shí)間,謝謝!
添加回答
舉報(bào)
0/150
提交
取消