我正在开发一个弹簧支架控制器。但是,当我尝试访问 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", "mike.john@gmail.com"); return customer; }甚至连消息也getIndex()没有打印出来。我尝试清理项目并清理 tomcat 目录,但没有任何改变。谁能告诉我问题出在哪里?
1 回答
千万里不及你
TA贡献1784条经验 获得超9个赞
哦伙计们,我解决了。这是该文件的拼写错误application.properties
。它被命名为“application.properities”。抱歉占用您的时间,谢谢!
添加回答
举报
0/150
提交
取消