用html发送ajax请求浏览器端报错
<html>
<head>
<meta charset="utf-8">
<title>title>
head>
<body>
<script type="text/javascript">
var xhr=new XMLHttpRequest()
window.onload=function(){
doucument.getElementById("in").onclick=function(){
xhr.open("POST","/ajax","ture")
var name=doucument.getElementById("name").value()
var pass=doucument.getElementById("pass").value()
xhr.setRequestHeader("content-Type","application/x-www-form-urlencoded")
xhr.send(name,pass)
if(xhhr.onreadystatechange==4){
document.getElementById("span").innerHTML=xhr.responseText
}
}
}
script>
用户名<input type="text" name="name" id="name" value="" /><br>
密码<input type="password" name="pass" id="pass" /><br>
<input type="button" name="" id="in" value="提交" />
<span id="span">span>
body>
html>
报错为
最有可能是是缺少Jackson的包?添加Jackson的依赖就可以;
还有web.xml中前端控制器的拦截形式为 *.html,这种可以修改web.xml,此请求使用其他的拦截形式。
语法错误
是document,不是doucument