I have a simple @Controller
within a spring-mvc
environment. This is the Controller:
@Controller
public class MessageController {
private static Logger LOG = LoggerFactory
.getLogger(MessageController.class);
@RequestMapping(value = "/messages/{userId}/{messageId}", method = RequestMethod.GET)
public Message getMessage(@PathVariable("userId") String uid,
@PathVariable("messageId") String msgid) {
LOG.trace("GET /message/{}/{}", uid, msgid);
return new Message();
}
}
This is the servlet-mapping in web.xml
:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Messaging Service</display-name>
<servlet>
<servlet-name>messaging</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>messaging</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
When I start the app via jetty and run a request against /messages/abc/def
, I get the following log:
INFO: Mapped "{[/messages/{userId}/{messageId}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public ....Message ....MessageController.getMessage(java.lang.String,java.lang.String)
WARNING: No mapping found for HTTP request with URI [/messages/abc/messages/abc/def] in DispatcherServlet with name 'messaging'
What did I do wrong here? The request definitely only contains /messages/abc/def
, why is this internally translated to /messages/abc/messages/abc/def
?
<servlet-mapping>
section ofweb.xml
file. – Grethelweb.xml
to the question. – Crevice@ResponseBody
. – Crevice