Question

I am working on spring.I am unable to create mapping for this url in "abc.com/firstName.lastName" sping.if i have write this code

@RequestMapping(value = "/{path}", method = RequestMethod.GET, produces = "application/json")
@Timed
public void saveProfileMapping(@PathVariable String path)
{
    System.out.println("-------------getting Mapping--------------"+path);
} 

Then get only firstname i.e lastname is not get in spring.but if write like that

@RequestMapping(value = "/{firstName}.{lastName}", method = RequestMethod.GET, produces = "application/json")
@Timed
public void saveProfileMapping(@PathVariable String firstName,String lastName)
{
    System.out.println("-------------getting Mapping--------------"+firstName+lastName);
}

Same result here get only firstname.

Please need your help..

Thanks in advance.

Était-ce utile?

La solution

You need to PathVariables's:

...
public void saveProfileMapping(@PathVariable String firstName,@PathVariable String lastName)
...

Hope that helps!

Autres conseils

Marten identified the problem correctly. An alternative (easier) solution is to use a regex in the @RequestMapping e.g. this matches everything:

 @RequestMapping(value = "/{path:.*}")
 public void saveProfileMapping(@PathVariable String path)
 { ... } 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top