No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zmh458/article/details/83051333

前言

最近在做一个商场的项目,在做这个项目的时候真的是一步一个bug啊,还真的是成长了不少啊。


#叙述

bug

我在搭建一个宜立方的项目时遇到了这个问题:No mapping found for HTTP request with URI [/mycart1/index.do] in DispatcherServlet with name ‘spring’


bug分析

    产生原因: IndexController类里没有加controller的注解。如下:

...

import org.springframework.web.bind.annotation.RequestParam;
import org.wltea.analyzer.lucene.IKAnalyzer;


public class IndexController {
public static String INDEX_PATH = "C:/Users/Administrator/Desktop/testSearchEngineDemo/createdIndex";
public static String DATA_PATH = "C:/Users/Administrator/Desktop/testSearchEngineDemo/data";
public static Analyzer ANALYZER = new IKAnalyzer();

        .....

}

    解决办法:在 IndexController类里加上“@Controller”。如下:

...

import org.springframework.web.bind.annotation.RequestParam;
import org.wltea.analyzer.lucene.IKAnalyzer;


@Controller
public class IndexController {
public static String INDEX_PATH = "C:/Users/Administrator/Desktop/testSearchEngineDemo/createdIndex";
public static String DATA_PATH = "C:/Users/Administrator/Desktop/testSearchEngineDemo/data";
public static Analyzer ANALYZER = new IKAnalyzer();
...

}

#小结
无处不bug,无处不生活。
感谢您的阅读~~

猜你喜欢

转载自blog.csdn.net/zmh458/article/details/83051333