in client, the javascript code:
<script src="api/api.js?v=1.x&key=abjas23456asg" type="text/javascript"></script>
when browser meet this line, I guess it will send get request to the server and get the content in api.js.
but I want to process this get request, and do some other trim on content according to parameters which are v and key.
for example:
when the key is not valid, we just return a alert string but not a real api.
in order to do this you will need to first configure your web.xml which redirects request of .js to spring instead of directly serving.
then you will need to write Request Handler using HandlerInterceptorAdapter to intercept request and verify key parameter. if it is not available then just push alert code and dont allow further request chain to be processed by sending flase as result of preHandle.
and you can map static resources using
To configure web.xml for all resources you can set
For HandlerInterceptor
for web context xml