Retrieve the fragment (hash) from a URL and inject the values into the bean

后端 未结 5 813
不思量自难忘°
不思量自难忘° 2020-12-14 20:03

I am looking for a way to inject values from the fragment (#) of a URL into bean(JSF), in the same way query-parameter values are injected. I am using Ben Alman\'s Bookmarka

5条回答
  •  爱一瞬间的悲伤
    2020-12-14 20:56

    Here's the most reliable way to extract a fragment from a syntactically valid URL / URI.

     URI uri = new URI(someString);
     String fragment = uri.getFragment();
    

    How you inject this into a bean will depend on what server-side framework you are using, and whether you are doing the injection using XML or annotations, or doing it programmaticaly.

提交回复
热议问题