Grails application context in javascript library
问题 Is it possible to access grails.app.context from within a javascript library? --That is, not javascript inserted in a GSP file. I have som javascripts that are context dependent, why I need to be able to access this from javascript. I include the javascript in my gsp-files with: <r:require modules="myModule" /> 回答1: You can pass it to Javascript as global JS variable, put this inside <head> tag: <g:javascript> window.appContext = '${request.contextPath}'; </g:javascript> and use it anywhere