springboot项目 Did not find handler method for

qq_26846599 qq_26846599 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

项目结构如上:
部分代码:
@Configuration
@ComponentScan(basePackages = { "com.tianan.*" })
public class TokenCheckConfig extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 拦截API请求
registry.addInterceptor(new TokenCheckInterceptor()).addPathPatterns("/**");
super.addInterceptors(registry);
}
}
##################################################################
@Component
public class SimpleCORSFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*");// 来允许任何站点对该资源进行跨域请求
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
chain.doFilter(req, res);
}

public void init(FilterConfig filterConfig) {
}

public void destroy() {
}
}
#########################################################
@Controller
@RequestMapping("/product")
public class ProductController {
@Autowired
private ProductService productService;

@RequestMapping(value = "/getProduct", method = RequestMethod.GET)
@ResponseBody
public String getProduct(Integer id) {
Product product = productService.findById(id.toString());
String jsonObject = JSONObject.toJSONString(product);
return jsonObject;
}
}
########################################################
http://127.0.0.1:8080/tiananServer/product/getProduct?id=1 通过这种方式去调用后台日志如下:
2017-02-22 17:43:51.729 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet -DispatcherServlet with name 'dispatcherServlet' processing GET request for [/tiananServer/product/getProduct]
2017-02-22 17:43:51.730 [http-nio-8080-exec-10] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping -Looking up handler method for path /product/getProduct
2017-02-22 17:43:51.731 [http-nio-8080-exec-10] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping -Did not find handler method for [/product/getProduct]
2017-02-22 17:43:51.732 [http-nio-8080-exec-10] DEBUG o.s.web.servlet.handler.SimpleUrlHandlerMapping -Matching patterns for request [/product/getProduct] are [/**]
2017-02-22 17:43:51.732 [http-nio-8080-exec-10] DEBUG o.s.web.servlet.handler.SimpleUrlHandlerMapping -URI Template variables for request [/product/getProduct] are {}
2017-02-22 17:43:51.732 [http-nio-8080-exec-10] DEBUG o.s.web.servlet.handler.SimpleUrlHandlerMapping -Mapping [/product/getProduct] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@7a729f84]]] and 1 interceptor
2017-02-22 17:43:51.732 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet -Last-Modified value for [/tiananServer/product/getProduct] is: -1
2017-02-22 17:43:51.733 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet -Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-02-22 17:43:51.734 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet -Successfully completed request
2017-02-22 17:43:51.735 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet -DispatcherServlet with name 'dispatcherServlet' processing GET request for [/tiananServer/error]
2017-02-22 17:43:51.735 [http-nio-8080-exec-10] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping -Looking up handler method for path /error
2017-02-22 17:43:51.735 [http-nio-8080-exec-10] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping -Returning handler method [public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)]
2017-02-22 17:43:51.735 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet -Last-Modified value for [/tiananServer/error] is: -1
2017-02-22 17:43:51.738 [http-nio-8080-exec-10] DEBUG o.s.w.s.m.m.annotation.HttpEntityMethodProcessor -Written [{timestamp=Wed Feb 22 17:43:51 CST 2017, status=404, error=Not Found, message=No message available, path=/tiananServer/product/getProduct}] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@65ebe654]
2017-02-22 17:43:51.738 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet -Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-02-22 17:43:51.738 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet -Successfully completed request

怎么解决此问题,谢谢大侠帮忙。其他代码如需看下单独发代码包。
...全文

相关推荐

unable to find valid certification path to requested target 的问题

NULL 博文链接:https://hyl198611.iteye.com/blog/1988113

weixin_38669628

jsp自定义标签

jsp自定义标签,比如说if,foreach,out,format

湮顾千古

适合高校科研人员发布成果、寻找承接企业的靠谱技术转移平台有哪些?.docx

科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

省级技术转移服务机构平台在支撑区域科技大脑建设方面能提供哪些数据服务?.docx

科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

YOLO26算法城市道路交通标志目标检测+训练好的模型+8089张数据集+pyqt可视化界面-sts

文末有数据集可视化效果,供参考。YOLO26算法城市道路交通标志目标检测+训练好的模型+8089张数据集+pyqt可视化界面本资源由 sts 账号整理发布,标注齐全,开箱可训。

stsdddd
评论 1
收藏 已收藏
分享
返回顶部
qq_26846599
Java EE 67,535 成员 225,843 内容