功能实现:

在jsp页面中填写文本框内容,光标离开文本框,在本页面的相应地方获取数据库中改值所对应的其他数据。

servlet:

      request.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
// 调用servlet层去数据库查找是否有相同用户名 并返回到页面中的其他记录
String client_id = request.getParameter("client_id");
ClientServices clientServices = new ClientServices();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Client client = clientServices.findClientById(client_id);
if (client != null) {
out.print(URLEncoder.encode(client.getClient_name(), "utf-8"));
} else {
out.print("false");
}
out.flush();
out.close();

jquery:

 $(document).ready(function() {
$("#client_id").blur(function() {
$.ajax({
type : 'POST',
url : 'servlet/validServlet?client_id=' + $(this).val(),
data : 'client_id=' + $("#client_id").val(),
success : function(msg) {
if (msg == 'false') {
alert("没有此人");
} else {
//utf-8解码解决中文乱码
$("#clientInfo").html(decodeURI(msg));
$("#clientInfo").attr("value", decodeURI(msg));
}
}
});
});
});

最新文章

  1. Java 中使用javah编译头文件出现找不到类的情况
  2. winform 可拖动的自定义Label控件
  3. SLAM拾萃(3):siftGPU
  4. vc设置按钮文字颜色
  5. [Ruby] Ruby Variable Scope
  6. group by 汇总
  7. Dubbo源码学习--服务发布(ServiceBean、ServiceConfig)
  8. 第二十六天 蛰伏的Hibernate遇到春日的暖阳 —Spring MVC 集成Hibernate使用(一)
  9. 有奖试读—Windows PowerShell实战指南(第2版)
  10. 利用pytesser识别图形验证码
  11. Spring Bean 生命周期测试
  12. QGridLayout
  13. 安卓程序中手机后退键与标题栏后退键是不同的,前者回出发onBackPressed()函数,后者需要重重写temclick函数
  14. Linux环境下Node.js的安装配置
  15. Notepad++ 列操作
  16. json等序列化模块 异常处理
  17. 半夜思考, 为什么建议重写 equals() 方法时, 也要重写 hashCode() 方法
  18. nvidia显卡驱动
  19. 1: 介绍Prism5.0(纯汉语版)
  20. jmeter聚合报告详解

热门文章

  1. (转) Pointers
  2. MVC再次学习1
  3. 微信开发之门店管理{"errcode":40097,"errmsg":"invalid args hint: [xxxxxxx]"}
  4. Firebug介绍及使用技巧
  5. pubwin会员合并
  6. 阿里巴巴JAVA常考面试题及汇总答案
  7. 学习http的一个网站
  8. CentOS6下编译安装Python2.7.6方法
  9. Bitmap 与ImageSource之间的转换
  10. Quartz.NET作业调度框架详解