我在调用 servlet 时遇到问题,所以我需要帮助。这是我的 web.xml
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/test/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ajaxServlet</servlet-name>
<servlet-class>org.finki.exercise.servlet.AjaxServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ajaxServlet</servlet-name>
<url-pattern>/ajaxServlet/*</url-pattern>
</servlet-mapping></servlet>
我有一个用于测试目的的 jsp 页面,我试图从 ajax 调用 servlet
<a href="#" onclick="loadXMLDoc('eva')">proba</a>
阿贾克斯的乐趣
function loadXMLDoc(value1)
{
var xmlhttp;
var url="ajaxServlet";
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("mid_title").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", url+"?url="+value1, true);
xmlhttp.send();
}
函数 loadXMLDoc 调用调度程序 servlet http://localhost:8097/mavenproject1/test/ajaxServlet
。
如何调用 ajaxServlet - http://localhost:8097ajaxServlet
?