Following is the Javascript function which is using AJAX call in my Spring MVC application :-
function someAjax(){
if(window.XMLHttpRequest){
http = new XMLHttpRequest();
}
var username = document.getElementById("username").value;
http.open("GET", "AjaxSameUser?username="+username, true);
http.onreadystatechange=handleResponse;
http.send(null);
}
“AjaxSameUser” is RequestMapped to a Controller, which redirects to AjaxSameUser.jsp.
I am also able to get static content from AjaxSameUser.jsp and use it using http.responseText.
Now, I want to access username in this Controller. How do I do this??
Actually this is the username of a signup page. I want to check whether the username entered by user is already present in the current database.
I have tried using @ModelAttribute considering that username would be set in the request scope. But I am not able to access this value set from Javascript.
Use
If the username is optional, Use