I'm hoping this isn't too simple of a question. I'm new to the java web services world and cant seem to get access to my PathVariables in my controller. I'm using STS and it's not complaining that my syntax is wrong.
So more important than the correct answer, I'd really like to know why this isn't working.
Here's some example code that I cant get to work:
@RestController
public class TestController {
@RequestMapping("/example")
public String doAThing(
@PathVariable String test
) throws MessagingException {
return "Your variable is " + test;
}
}
If I run a curl against it like so:
curl http://localhost:8080/example?test=foo
I receive the following response:
{"timestamp":1452414817725,"status":500,"error":"Internal Server Error","exception":"org.springframework.web.bind.MissingPathVariableException","message":"Missing URI template variable 'test' for method parameter of type String","path":"/example"}
I know that I have everything else wired up correctly, other controllers work.
I feel like I must be missing some fundamental principal here.
Thanks in advance.