jquery alidate和form整合不能提交数据

index.jsp文件[color=red][/color]
<%@page pageEncoding="UTF-8" language="java"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主页</title>
<style>
   *{
   font-family:Verdana, Geneva, sans-serif;
   font-size:96%;
   }
   label{
   width:10em;
   float:left;
   }
   label.error{
   float:none;
   vertical-align:top;
   padding-left:5em;
   color:red;
   }
   p{
   clear:both;
   }
   .submit{
   margin-left:12em;
   }
   em{
   font-weight:bold;
   padding-right:5em;
   vertical-align:top;
   }
   em.error{
   background:url(error.gif) no-repeat 0px 0px;
   padding-left:160px;
   }
   em.success{
   background:url(success.gif) no-repeat 0px 0px;
   padding-left:160px;
   }
  
</style>
<script src="jquery.js"></script>
<script src="jquery.validate.js"></script>
<script src="messages_cn.js"></script>
<script src="jquery.form.js"></script>
<script>
     function showResonse(responsedText,statusText){
     alert("状态"+statusText+"\n返回结果\n"+responsedText);
  }
  var options1={
     target:'#showResult'
//beforeSubmit:validateForm,
//success:showResonse,
// url:"/jqueryForm/ResponseServlet"
//type:
//dateType:
//clearForm:
//resetForm:
//timeout:
  };
  function validateForm(){
      //alert($.param(formData));
      $.validator.addMethod("formula",
                        function(value,element,param){
             return value==eval(param);
           },
"请输入数学公式计算后的结果");
     $("#validateForm").validate({
   rules:{
      cusername:{required:true,minlength:2},
  fname:{required:true,minlength:2},
  cemail:{required:true,email:true},
  curl:{required:true,url:true},
  valcode:{formula:"7+9"},
  upload:"required"
 
   },
   groups:{ cusername:"fname lname" },
   errorPlacement:function(error,element) { if (element.attr("name") == "fname" || element.attr("name") == "lname") error.insertAfter("#lastname"); else error.insertAfter(element); },
   errorElement:"em",
   submitHandler:function(form1){
             $(form1).ajaxSubmit(options1);
         },
   success:function(label){
               label.text("").addClass("success");
            }
});
  }

 
  $(function(){
   $("#validateForm").validate({
       submitHandler:function(form1){
             $(form1).ajaxSubmit(options1);
         }
   });
  });
</script>
</head>

<body>
<form action="/jqueryForm/ResponseServlet" method="post" id="validateForm"  enctype="multipart/form-data">
  <fieldset>
    <legend>validate表单验证</legend>
  
    <p>
      <label for="fname" title="firstname">firstname</label>
      <input type="text" id="fname" name="fname"  size="25"/>
       <em></em>
    </p>
    <p>
      <label for="lname" title="lastname">lastname</label>
      <input type="text" id="lname" name="lname"  size="25"/>
       <em id="lastname"></em>
    </p>
     <p>
      <label for="curl" title="网址">网址</label>
      <input type="text" id="curl" name="curl" size="25"/>
       <em></em>
    </p>
     <p>
      <label for="cemail" title="email">email</label>
      <input type="text" id="cemail" name="cemail" size="25"/>
       <em></em>
    </p>
     <p>
      <label for="valcode" title="验证¯">7+9</label>
      <input type="text" id="valcode" name="valcode"  size="25"/>
       <em></em>
    </p>
    <p>
      <label for="upload" title="upload">upload</label>
      <input type="file" id="upload" name="upload" />
       <em></em>
    </p>
     <p>
      <label for="ccomment" title="评论" >评论</label>
      <textarea id="ccomment" name="ccomment" col="25" class="required"></textarea>
       <em></em>
    </p>
     <p>
      <input type="submit" class="submit" value="提交"/>
    </p>
  </fieldset>
</form>
<div id="showResult"></div>
</body>
</html>
resopnseServlet.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package 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;

/**
*
* @author Administrator
*/
public class ResponseServlet extends HttpServlet {

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       String fname=req.getParameter("fname");
       String lname=req.getParameter("lname");
       String curl=req.getParameter("curl");
       String cemail=req.getParameter("cemail");
       String comment=req.getParameter("ccomment");
       String result=fname+"&"+lname+"&"+curl+"&"+cemail+"&"+comment;
       resp.getWriter().println(result);
    }
  
}
我用jqury的form框架和validate框架做了一个提交表单数据给servlet,但是提交不了,servlet得不到数据的,都是null,是不是这两个框架不能一起使用啊,请高手帮忙解决

你可能感兴趣的:(jquery,jsp,框架,servlet,XHTML)