0

I would like to use URL http://localhost:8080/blog#section & obtain #section as a variable in getBlog() method.

// localhost:8080/blog#section
@GetMapping("/blog/{section}")
public String getBlog(Model model, @PathVariable("section") String section){
    return "blog" + section; // localhost:8080/blog#section
}
Ted
  • 78
  • 7

1 Answers1

2

The #section part is never sent to server (see this answer),so what you are demanding is impossible.

In fact #section is used for browser to locate the content of a web page, it's not used for server to decide which content to return.

What you are demanding can be easyily achieved with a query like localhost:8080/blog?section=? or a url path like localhost:8080/blog/section

haoyu wang
  • 1,241
  • 4
  • 17