js浏览器刷新页面 ajax应用开发典型实例|AJAX应用之草稿自动保存(15)

电脑杂谈  发布时间:2018-02-04 11:02:02  来源:网络整理

再看看数据提供者的URL,url = "/chkUserAndCom",servlet如下:

以下是引用片段:

以下为引用的内容:

1/**//*

2 * Created on 2005-12-31

3 *

4 * TODO To change the template for this generated file go to

5 * Window - Preferences - Java - Code Style - Code Templates

6 */

7package com.event;

8

9import javax.servlet.ServletException;

10import javax.servlet.http.HttpServletRequest;

11import javax.servlet.http.HttpServletResponse;

12

13import com.beans.EBaseInfo;

14

15/** *//**

16 * @author Alpha 2005-12-31

17 *

18 * <P>Ajax 演示---企业注册时检查企业用户名和企业名称</P>

19 *

20 * TODO To change the template for this generated type comment go to

21 * Window - Preferences - Java - Code Style - Code Templates

22 */

23public class CheckUserAndComNm {

24 private String msgStr = "";

25 protected void doGet(HttpServletRequest request,HttpServletResponse response)

26 throws ServletException

27 {

28

29 EComBaseInfo info=new EComBaseInfo();

30 String oprate=request.getParameter("oprate")).trim();

31 String userName=request.getParameter("userName");

32 String passWord=request.getParameter("password");

33 String comName=request.getParameter("comName");

34

35 try

36 {

37 if(oprate.equals("chkUser"))

38 {

39 response.setContentType("text/html;charset=GB2312");

40 if(userName.length()<5||userName.length()>20)

41 {

42 msgStr = "对不起,用户名必须为字母、数字或下划线,长度为5-20个字符!";

43 }

44 else

45 {

46 boolean bTmp=info.findUser(userName); //找查中有无该用户名

47 if(bTmp)

48 msgStr ="对不起,此用户名已经存在,请更换用户名注册!";


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-64907-15.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...