I use Spring Mvc and I would like to use an EL variable (e.g. ${pageContext.request.contextPath}) in a .js javascript file.
Is this possible? If so how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can make a template that contains the JS, and pass the contextPath as a variable that’s interpolated into the template.
But why do you need to do this? The context path is available in the client as wellEdit:
For this to work you might have to set up a ViewResolver so that the template is processed (if you don’t have one already).
In the page you just include the script as normal: