Ajax连接servlet连接问题 ajax无法访问servlet?
前端HTML
请点击
Ajax代码
$("#getvalue").click(function(){
$.ajax({
url:"/servlet/doajax",
cache:true,
type:"GET",
data:{username:"admin"},
async:false,
datatype:"html",
error:function(request){
alert("cuowu");
},
success:function(data){
$("#value").html(data);
}
});
});
servlet代码
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
String username = request.getParameter("username");
System.out.println(username);
PrintWriter out = response.getWriter();
out.print("welcome "+username);
out.flush();
out.close();
}
xml配置
This is the description of my J2EE component
This is the display name of my J2EE component
doajax
servlet.doajax
doajax
/servlet/doajax |
免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。
版权声明:作者保留权利,不代表天盟立场。
|
|
|
|