我按韩顺平老师讲的servlet中用户管理系统写代码,接收参数无反应,请大家帮忙看下!
web.xml<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>w.sj.Hello</servlet-class>
</servlet>
<!-- Define the Manager Servlet Mapping -->
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>w.sj.Login</servlet-class>
</servlet>
<!-- Define the Manager Servlet Mapping -->
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>logincl</servlet-name>
<servlet-class>w.sj.Logincl</servlet-class>
</servlet>
<!-- Define the Manager Servlet Mapping -->
<servlet-mapping>
<servlet-name>logincl</servlet-name>
<url-pattern>/logincl</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>wel</servlet-name>
<servlet-class>w.sj.Wel</servlet-class>
</servlet>
<!-- Define the Manager Servlet Mapping -->
<servlet-mapping>
<servlet-name>wel</servlet-name>
<url-pattern>/wel</url-pattern>
</servlet-mapping>
</web-app>
Login.javapackage w.sj;
import javax.servlet.http.*;
import java.io.*;
public class Login extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
{
try
{
res.setContentType("text/html;charset=gbk");
PrintWriter pw=res.getWriter();
pw.println("<html>");
pw.println("<body>");
pw.println("<hl>请输入用户名和密码<hl>");
pw.println("<form action=logincl method=post>");
pw.println("用户名<input type=text name=usrname><br>");
pw.println("密 码<input type=password name=pwd><br>");
pw.println("<input type=submit value=login><br>");
pw.println("</form>");
pw.println("</body>");
pw.println("</html>");
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public void doPost(HttpServletRequest req,HttpServletResponse res)
{
}
}
Logincl.javapackage w.sj;
import javax.servlet.http.*;
import java.io.*;
public class Logincl extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
{
try
{
res.setContentType("text/html;charset=gbk");
PrintWriter pw=res.getWriter();