I am trying to implement simple web service that takes userId and shows some user rated info information on HTML web page.
I tried to write some spring annotation based web service using spring mvc
When I tried to run following program, I got 404 error.
http://localhost:8080/EdgeStore/execute/user1
Its simple program that I have written. Am I missing something in this program ?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
<context:component-scan base-package="EdgeStore"/>
<mvc:annotation-driven/>
</beans>
and dispatcher is
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:web="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID"
version="2.4">
<display-name>EdgeStore</display-name>
<servlet>
<servlet-name>EdgeStore</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>EdgeStore</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
And Controller is
package EdgeStore;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
@Controller
@RequestMapping("/execute")
public class executeController {
@RequestMapping(value="/{userId}", method = RequestMethod.GET)
@ResponseBody
public UserProfile getUserProfile(@PathVariable("userId") String userId) {
UserProfile userProfile = new UserProfile();
userProfile.setUserId(userId);
userProfile.setSegmentId("defaultSegement");
return userProfile;
}
}