I am trying got use spring-mvc tag inside java-script file, here is what i am trying to do
var firstName="<spring:theme code='register.firstName.invalid' javaScriptEscape='true'> ";
seems like its not working as when using alert(firstName) its giving the same text and not the text from resource bundle.
Is there something i am doing wrong?
Standard javascript file aren’t processed by Spring, it’s just a static file, that served by web container as-is, w/o any transformation.
If you need to setup some Javascript variabled using server side logic (like Spring tags), you can do it inside JSP, and the use it from javascript.
Or also you can write your own request filter, that will process and transform your static files on the fly, but it’s major performance loss.