I am trying to create a RESTful web service using the Spring framework with Apache Tomcat. I added two controller classes that had about 5-6 endpoints that worked fine. But from yesterday, when I try to add another endpoint, I get a strange error.
@Controller
@RequestMapping("/test")
public class TextController {
@RequestMapping(method=RequestMethod.POST)
public void test() {
System.out.println("Hello world");
}
}
When I try to use this URL from a browser (using the REST client), I get the following output:
Hello world
Jun 25, 2014 7:05:55 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ChitChatApp/rest/test/test] in DispatcherServlet with name 'chitchat-dispatcher'
An optional "/ test" has been added to the URL. My other APIs are still working fine. Only the new ones that I add give this error.
My web.xml is as follows:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>ChitChat Web Service</display-name>
<servlet>
<servlet-name>chitchat-dispatcher</servlet-name>
<servlet-class> org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/chitchat-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>chitchat-dispatcher</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I don't know why it started all of a sudden. Thank you for helping with this.
araju