日期:2014-05-16  浏览次数:20396 次

servlet跳转问题,我觉得没有错误了,但最后结果出错,求帮助
1.ThreeParams.java
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 ThreeParams extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
         PrintWriter pw = response.getWriter();
         pw.println(request.getParameter("param1"));
         pw.println("<br>");
         pw.println(request.getParameter("param2"));
         pw.println("<br>");
         pw.println(request.getParameter("param3"));
         pw.println("<br>");
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
     doGet(request, response);
}
     
}
2.ThreeParams.html
<form id="form1" name="form1" method="get" action="ThreeParams">
   <table width="343" border="1">
       <tr>
       <td width="92">param1</td>
   <td width="94"><input name="param1" type="text" 

id="param1"/></td>
   </tr>
   <tr>
       <td>param2</td>
   <td><label>
        <input name="param2" type="text" id="param2"/>
   </label></td>
   </tr>
   <tr>
        <td>param3</td>
<td><input name="param3" type="text" id="param3"/></td>
</tr>
<tr>
    <td>&nbsp;</td>
<td><label>
    <input type="submit" value="提交"/>
</label></td>