日期:2014-05-17 浏览次数:20823 次
<body>
<form id="frmV">
<div class="divFrame">
<div class="divTitle">请输入下列资料</div>
<div class="divContent">
<div>用户名:<br>
<input id="username" name="username" type="text" class="txt" />
<font color="red">*</font><br>
<span></span>
</div>
<div>邮箱:<br>
<input id="email" name="email" type="text" class="txt" />
<font color="red">*</font><br>
<span></span>
</div>
<div class="divBtn">
<input id="sbtUser" type="submit" value="提交" class="btn" />
</div>
<div class="divData">
</div>
</div>
</div>
</form>
</body>
<script type="text/javascript">
$(function(){
var options = {
url: "http://localhost:8080/jquery/JqueryTest003Servlet",
type: "POST",
clearForm: true,
target: "#divData"
}
$("#frmV").ajaxForm(options);
});
</script>
public class JqueryTest003Servlet extends HttpServlet {
private static final long serialVersionUID = 445895022678314316L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = request.getParameter("username");
String email = request.getParameter("email");
System.out.println("Username: " + username+ ";Email: " + email);
PrintWriter out = response.getWriter();
out.write("Username: " + username+ ";Email: " + email);
out.flush();
out.close();
}
}