Home  >  Q&A  >  body text

java - How to get the address bar in velocity?

Like the title~~~

I have tried several methods on the Internet but all reported null pointers

code show as below

 <tool>
    <key>link</key>
    <scope>request</scope>
    <class>org.apache.velocity.tools.view.tools.LinkTool</class>
</tool>
伊谢尔伦伊谢尔伦2667 days ago1110

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-06-30 09:58:04

    The address bar can only be obtained in JavaScript scripts, using window.location. Reference documentation:
    https://developer.mozilla.org...

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-06-30 09:58:04

    As @fabricated belief said, you can use window.location to get the address bar (client-side method) on the web page.

    To obtain the address bar from the server side, use request.getRequestURL(), and the content after ? needs to be obtained from request.getQueryString(), and the content after # cannot be obtained.

    reply
    0
  • Cancelreply