我正在使用 Spring MVC,我需要对服务器进行异步调用并检查用户的凭据。如果匹配,那么我将重定向到另一个页面。
MyController.java
@RequestMapping("performingLogin.htm")
public ModelAndView performingLogin(@RequestParam String username, @RequestParam String password)
{
//boolean value which decides whether its a valid user
myService.performingLogin(username, password);
//Currently returning the new model to be opened irrespective of valid user
ModelAndView model = new ModelAndView("newpage");
return model;
}
主视图.jsp
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function doAjaxPost() {
$.ajax({
url : "dologin.htm",
data : {
username: $('#username').val(),
password: $('#password').val()
},
success : function(responseTxt,statusTxt,xhr) {
/* Opening new page */
window.location.href="newpage.htm";
}
});
}
我需要知道如何在 JSP 端验证用户,以便发出凭据不正确的警报。