最近闲来无事弄了一下jquery。顺便练习一下基本语句,并尝试着用用封装好的ajax特性
以下是简单知识点的总结:
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="js/jquery_1.4_All.js"></script>
<script type="text/javascript">
function doRequest1(){
$.ajax({
type:"post",
url:"loginServlet",
data:"username="+$("#username").val()+"&password="+$("#password").val(),
success:function(msg){
$("#msg").text(msg);
$("#msg").val(msg);
}
});
};
</script>
</head>
<body>
<div>
<form action="#">
用户: <input type="text" name="username" id="username"/>
密码: <input type="text" name="password" id="password"/>
<input type="button" id="send" value="提交" onclick="doRequest1();"/>
<span id="msg"></span>
</form>
</div>
</body>
</html>
package beyondx.ajax;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class LoginServlet extends HttpServlet{
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String username = request.getParameter("username");
String password = request.getParameter("password");
PrintWriter out = response.getWriter();
if(username.equals("zzz")&&password.equals("111")){
out.print("welcome "+username);
}
else out.print("账号密码错误");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>loginServlet</servlet-name>
<servlet-class>beyondx.ajax.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>loginServlet</servlet-name>
<url-pattern>/loginServlet</url-pattern>
</servlet-mapping>
</web-app>
希望对想了解jquery的朋友有所帮助。
分享到:
相关推荐
初试 Jquery EasyU IDemo, 一步步教你做个系统的组件。
中国海洋大学-非全日制研究生_910计算机技术01_专硕资料_初试资料_完整版
福州大学研究生复试和初试模电真题_2...
福州大学研究生复试和初试模电真题_3...
福州大学研究生复试和初试模电真题_1.。。。。
jQuery EasyUI是一组基于jQuery的UI插件集合,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面。开发者不需要编写复杂的javascript,也不需要对css样式有深入的了解,开发者需要了解...
拿出来我们上次准备好的东西.1:XMLHTTPRequest对象的函数.2:Asp输出xml格式的文件....并附上效果演示 web_ajax.asp 代码如下: <?xml version=”1.0″ encoding=”gb2312″ ?> <body> 一个简单的Asp
六年级初试试题A卷_第四届创新杯(扫描版,无答案).doc
研究生初试录取信息管理系统 课程设计 说明书
csp - j初试模拟卷.docx csp - j初试模拟卷.docx csp - j初试模拟卷.docx csp - j初试模拟卷.docx csp - j初试模拟卷.docx csp - j初试模拟卷.docx csp - j初试模拟卷.docx csp - j初试模拟卷.docx csp - j初试模拟...
1_初试-招聘题.zip
课程设计中的使用visual studio编写的c++代码,研究生初试录取管理系统,任务书已经找不到了,,,所有代码+调试文件如上
武汉科技大学 计算机 考研 软件工程初试 包含 -- 期末考试试卷 -- 真题 --预测
最新人教版小学四年级语文下册《交流平台_初试身手》精品课件-.pdf
国家对初试录取分数有总分要求(如某一年要求4门课总分应达到310分),另外还有对每门课的最低分数要求(如总分为100的试卷最低应达到40分,总分为150的试卷最低应达到65分)。编程统计初试合格的人数,并按总分由高...
应聘人员初试测评表 评价人姓名: 职务: 面试时间: 应聘人姓名: 性别: 年龄: 编号: 应聘职位: 原单位: 评价方向 评价要素 评价等级 1(差) 2(较差) 3(一般) 4(较好) 5(好) 个人基本素质 评价 1、...
安徽大学,计算机科学与技术,考研初试资料,希望能帮助到各位考研er 考研初试资料 考研初试资料 考研初试资料
2022年硕士研究生招生考试初试试题.rar; filename_=utf-8''2022年硕士研究生招生考试初试试题.rar;
研究生初试录取代码 java 操作 绝对经典