I am trying to expose a REST API via Spring MVC+REST with some Spring Security configuration. However, I am getting 404.
Here's the code.
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app ...>
<display-name>REST Project</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
rest-servlet:
<?xml version="1.0" encoding="UTF-8"?>
<beans ... />
<mvc:annotation-driven />
</beans>
mvc-config:
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- Example: a logical view name of 'showMessage' is mapped to '/WEB-INF/jsp/showMessage.jsp' -->
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
applicationContext:
<?xml version="1.0" encoding="UTF-8"?>
<beans ... ">
<context:component-scan base-package="org.my.project" />
</beans>
Finally, Service REST controller
@RestController
@RequestMapping("/service")
public class Service {
@RequestMapping(value = "/public/{name}", method = RequestMethod.GET)
public String storeEntityPublic(@PathVariable String name) {
// do something
return result;
}
}
URL: localhost:8080//service/public/aname
What am I missing?