这是一个WEB项目,需要在网页上显示,只是初学,没有涉及到后面一些东西。我把添加用户的代码放在了下面,用Myeclipse写的,我想加上Ajax让他注册不能重名,该在哪里做出修改呢?先谢谢大家了
这个是userAdd.jsp 增加用户的页面
<%@ page language="java" import="java.util.*" 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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
</head>
<body>
<div class="place">
<span>位置:</span>
<ul class="placeul">
<li><a href="index.jsp">首页</a></li>
<li><a href="#">添加账户</a></li>
</ul>
</div>
<div class="formbody">
<div class="formtitle">
<span>基本信息</span>
</div>
<div class="formbody">
<form action="<%=path%>/servlet/UserAddServlet" method="post" >
<ul class="forminfo">
<li><label> 用户名:</label><input name="uname" type="text" class="dfinput" ></li>
<li><label> 密码:</label><input name="upass" type="password" class="dfinput" ></li>
<li><label > 权限:</label></li>
<li><label style="margin-left: 150px">财务</label><input type="radio" name="quanxian" value="财务" checked="checked" style="margin-top: 12px" /></li>
<li><label style="margin-left: 150px">人事</label><input type="radio" name="quanxian" value="人事" style="margin-top: 10px" /></li>
<li><label> </label><input name="" type="submit"
class="btn" value="确认保存" /></li>
</ul>
</form>
</div>
</body>
</html>
下面这个是UserAddServlet 后台操作数据
package com.xx.servlet;
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;
import com.xx.bean.User;
import com.xx.dao.UserDao;
三国纷争
青春有我
浮云间
相关分类