views:

28

answers:

1

I am using JQuery ajax in Spring MVC 3. When making the following call, I am running into a dilemma with myurl. On the local development machine, myurl would be localhost:8080/myapp/my_json_controller. On the production, my url would be domain/my_json_controller. I tried using relative url, /my_json_controller, and it would not work on the development machine because of the /myapp part. Any suggestion on how to make this work on both production and development? Thanks!

$.ajax({
     url: myurl,
     data: mydata,
     dataType: 'json',
     type: 'get',
     cache: false,
     success: function ()
});
+1  A: 

It is not a good idea include '/myapp' in your application source code. You should be able to access your controller only writing its name.

Have you tried using, in your JSP, <c:url ...> tag? It can help you hiding your application base URL.

Sinuhe