currently my Controller looks like this.
@RequestMapping("members") public class MembersController { private ArrayList<Member> memberList = new ArrayList<>(); @GetMapping("") public String index1(Model model) { model.addAttribute(memberList); return "members/memberIndex"; } @GetMapping("index") public String index2(Model model) { model.addAttribute(memberList); return "members/memberIndex"; } }
Is there a easier way to have one index-method for two different paths "localhost:port/members" & "localhost:port/members/index"? Can I annotate two values for one method in general?
Thanks in advance:)
Edit: I have seen it work for @RequestMapping
You can use the value of @GetMapping as follows:
@GetMapping(value = {"/", "/index"})
I fixed it myself immediatly.
@GetMapping({"", "index"})
Didn't notice an array is necessary.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.