Reputation: 381
I'm trying Spring MVC,I tried @RequestMapping and @GetMampping annotation. There is something wired that @GetMapping doest not take effect. Below is the code:
@Controller
@RequestMapping(path="/service")
public class ServiceEntry {
@RequestMapping(path="/hello")
@ResponseBody
public String mainPage(){
return "Hello,Information";
}
@RequestMapping(path="/hello2", method = RequestMethod.GET)
@ResponseBody
public String page2(){
return "hello2!";
}
@GetMapping(path="/test1")
@ResponseBody
public String page_test1(){
return "Get method 1";
}
@GetMapping(path="/test2")
@ResponseBody
public String page_test2(){
return "Get method 2";
}
}
While I visit /service/hello or /service/hello2 it works, but /service/test1 or /service/test2 does not work, please help me, thanks!
Upvotes: 2
Views: 1053
Reputation: 336
In
RequestMapping
you can use parameterpath
but not inGetMapping
. You can do like this:GetMapping("/test1")
orGetMapping(value="/test1")
Upvotes: 3