i'm trying to have a JavaScript file call a JavaSpring MVC Controller, then the controller will perform its request mapping functions.
I'm not sure if it is also possible to pass a variable to the controller so it can know which specific mapping to perform. IF one could demonstrate how to do both that would be immensely helpful. If one can simply show me how to call a controller via JS that would be very helpful as well and answer the question.
my controller will look similar to the following:
@Controller
@RequestMapping(value = /waterquality/scale)
public class NmWaidsController {
@RequestMapping(value = {,/})
public String homePageWaids(){
return waterquality/scale/calmix;
}
I would like the JS to call this controller.
If possible I would like to do the following, and have the JS pass a variable to the method which would look like the following:
@Controller
@RequestMapping(value = /waterquality/scale)
public class NmWaidsController {
@RequestMapping(value = {,/})
public String homePageWaids(int viewChoice){
switch(viewChoice){
case 1:
return waterquality/scale/calmix;
break;
case 2:
return waterquality/scale/caloddo;
break;
case 3:
return waterquality/scale/calstiff;
break;
default:
return error;
break;
}
Any help would be much appreciated! Thanks in advance!