I'm running into a Spring (3.1) mapping conundrum: I have a simple, findAll method:
@RequestMapping( method = RequestMethod.GET )
@ResponseBody
public List< User > findAll(){
return findAllInternal();
}
This maps on the following URI (which is good): /user
.
However it also maps on: /user?bla=8
, which is not good.
Is there a way to explicitly specify the fact that this particular mapping contains no parameters?
I have tried to specify the params
in the @RequestMapping
but I can see no clear way of doing this.
Any help is appreciated.
Thanks. Eugen.
You can negate parameters in
@RequestMapping.param
attribute.As of spring 3.1 you can't explicitly disallow request to have parameters.
But to be honest it's rarely necessary.
There are three use cases:
bla
is a known parameter that you can explicitly allow/disallow.bla
is unknown parameter and can be ignored.The first two can be done in spring mvc. The third one, AFAIK, can't.
The third option is also potentially dangerous as you'd have to be really careful about the parameters the clients can send to your sever (like stuff added by security frameworks, etc).