Reputation: 737
Let's say I have a Java Spring MVC controller method like this:
@RequestMapping(value="showuser", method={RequestMethod.GET})
public ModelAndView showUser(Model model, @RequestParam Map<String,String> requestParams) throws Exception {
User has three fields (firstname, middlename, lastname) all of which are part of the unique ID for that record.
And middlename can be NULL.
I do this to view the user ...
http://localhost:8080/myapp/viewuser?firstname=Bob&middlename=Tiberius&lastname=Jones
And when middlename
is NULL, my code currently passes no value for middlename, like this ...
http://localhost:8080/myapp/viewuser?firstname=Bob&middlename=&lastname=Jones
... but doesn't work because in the requestParams
map, the value for middlename
gets set to empty string, not NULL.
I need that value to be NULL, not empty string.
How do I pass NULL as the value for the middlename
parameter?
I searched and found other answers that said to use %00
or %A0
for the value, but neither of these worked. Any ideas?
Upvotes: 1
Views: 2043