Assumptions, I am new to Spring MVC, JSP, Scripting/Ajax
Here's my task.
In Spring MVC, I have buttons in my jsp page, on button click, I want to perform some task (controller method), which doesn't return anything. I want to show the same page. It shouldn't reload the page nor should redirect to some other page.
Here's what I am doing...
I have a page with lots of buttons. I am using bootstrap css and button tag. like,
Start
On this button click, I am calling an Ajax to the method from controller,
$('#startApp').click(function() { BootstrapDialog.show({ message : 'Sure ?!', buttons : [ { label : 'Ok', cssClass : 'btn-default', action : function(dialogItself) { $.ajax({ type : "POST", url : "/MyApp/startApp", success : function(response) { alert("Success"); } }); dialogItself.close(); } }, { label : 'Close', action : function(dialogItself) { dialogItself.close(); } } ] });
This calls the controller method,
@RequestMapping(value = "/startApp", method = RequestMethod.POST) public void start() {// some operation.}
However, when I do this, operation is performed but in logs I am getting below error,
root cause dispatcher: com.ibm.ws.jsp.webcontainerext.JSPErrorReport: JSPG0036E: Failed to find resource /WEB-INF/views/startApp.jsp
Questions,
- Is it the right way to do ?
- I don't want to redirect to startApp.jsp, I want it to return to my index.jsp (where the code resides), how can I achieve this ?