I'm having trouble with Spring MVC RequestMapping and I'm hoping someone can give me advice on how to proceed.
I'm working on a server that will be accessed by a legacy client. The client sends simple requests (see below) but cannot be changed in any way to accommodate the new server.
The client sends gets or posts of the form /dbintf?command=GETINFO,acctNum=111 The server is called dbintf and it returns a simple text response.
I would like to create a Spring controller for each command and annotate a single controller method with a params mapping that is based on the command parameter. So the mapping in the GETINFOController would be:
@RequestMapping(params="command=GETINFO")
public String serviceRequest(....
However, I cannot get this to work. Here are some details of the service.
The servlet mapping in web.xml:
<servlet-mapping>
<servlet-name>dbintf</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
The annotation scanning directives in intf-servlet.xml
<context:component-scan base-package="com.intf.controller" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
I have been trying various combinations of things to try to get this scheme to work and I'll boil this trial-and-error work down to two examples:
This does not work. The response is: "The requested resource () is not available."
@RequestMapping( params="command=GETINFO")
public class TESTController {
@RequestMapping( method = RequestMethod.GET)
public String serviceRequest
If I change the url to add another level: /dbintf/test?command=GETINFO,acctNum=111 it works if I add a URL pattern to the handler method annotation.
@RequestMapping( params="command=GETINFO")
public class TESTController {
@RequestMapping( value="/test",method = RequestMethod.GET)
public String serviceRequest
This makes me think that params mapping alone will not work. It appears that a URL pattern must be part of any mapping scheme. For my case however, there is no URL pattern available since the the client request URL is fixed as: dbintf?..... My question: is it possible to use parameter based mapping alone and not in conjunction with a pattern? If so, what am I missing?
Thanks in advance for any help or advice, beeky