我在搭建一个Lucene的项目时遇到了这个问题:No mapping found for HTTP request with URI [/myLucene1/index.do] in DispatcherServlet with name 'spring'
产生原因: 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();
...
}