日期:2014-05-17  浏览次数:20676 次

求教,实在没搞懂why?
本帖最后由 xingshen100 于 2013-12-26 09:41:49 编辑
我做一个html页面,使用jQuery的load()函数去访问一个servelet,在myeclipse10.7下右键使用firefox运行html,页面可以正常显示,可是点击按钮后firebug中出现错误信息:



1.SerializeTest.html代码:

<!DOCTYPE html>
<html>
    <head>
        <title>SerializeTest.html</title>
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="js/jquery-1.8.3.min.js">
        </script>
        <script type="text/javascript">
            $(function(){
             $("form [type='button']").click(function(){
             var str=$("form").serialize();
             //alert(str);
             $("div").load("/Test/serialize?"+str,function(){
             alert($("div").val());
               });
              });
             }); 
        </script>
    </head>
    <body>
        <div id="d">
        </div>
        <form id="f">
            用户姓名:<input name="username" type="text">
            <br>
            密码         :<input name="password" type="text">
            <br>
            <input value="submit" type="button">
        </form>
    </body>
</html>



2.serialize.java servlet代码:

package cn.itcast.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.