这个SERVLET为什么不能用啊?

来源:百度知道 编辑:UC知道 时间:2024/05/04 10:14:08
package com.zym.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.zym.logical.LoginLogical;;

public class LoginServlet extends HttpServlet {

/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

首先,你需要在web.xml中将这个servlet配置进去。
其次,调用servlet时,如果没有指定method属性,默认调用的是doGet,而不是doPost();你可以把doGet()的方法体改为this.doPost(request,response);