本帖最后由 冯超 于 2013-3-31 11:14 编辑
1servlet文件- 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;
- public class registerServlet extends HttpServlet {
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- request.setCharacterEncoding("utf-8");
- response.setContentType("text/html; charset=UTF-8");
- //
- PrintWriter out = response.getWriter();
- String username = request.getParameter("username");
-
-
- out.println(username);
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- }
- }
复制代码 2.jsp文件不要说我路径写错了,不要问我xml文件是什么,那些都没有问题,为什么servlet传递过来的username的值为null,他也一直打印为null,写贴的过程中,突然觉得是不是XMLHttp.send()这个里面是不是一定要传递值,和服务器连接方式是不是一定要用post? 我只是把ajxa视频看了get方式,就做他说的那个案例,用get方式是不是不行啊? |