【发布时间】:2018-08-08 15:17:35
【问题描述】:
我正在尝试 Spring MVC,我尝试了 @RequestMapping 和 @GetMampping 注释。有一些东西连线@GetMapping 没有生效。 下面是代码:
@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";
}
}
当我访问 /service/hello 或 /service/hello2 时,它可以工作,但 /service/test1 或 /service/test2 不工作,请帮助我,谢谢!
【问题讨论】:
标签: spring model-view-controller