没有表单怎么提交到servlet
<form method="post" action="/servlet/SimpleController"
 <select name = "action"> 
  <option>  index </option> 
  <option>  displayList </option> 
   </select> 
   <input type ="submit" value="Select"/> 
</form>

解决方案 »

  1.   

    没有表单怎么提交到servlet 
    <form method="post" action="/servlet/SimpleController" 
      <select name = "action">   
       <option value="index">   index  </option>   
       <option value="displayList">   displayList  </option>   
        </select>   
        <input type ="submit" value="Select"/>   
    </form> 
      

  2.   

    首先看你的SimpleController。
    作为一个处理http请求的servlet只需继承HttpServlet即可
    import java.io.IOException;import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SimpleController extends HttpServlet
    {
    public void destroy()
    {
    // TODO Auto-generated method stub
    } protected void doGet(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException
    {
    doPost(request, response);
    } protected void doPost(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException
    {
    String action = request.getParameter("action");
    String jspPage = "/index.jsp";
    if ((action == null) || (action.length() < 1))
    {
    action = "/index.jsp";
    }
    if ("default".equals(action))
    {
    jspPage = "/index.jsp";
    } else if ("displayList".equals(action))
    {
    jspPage = "/displayList.jsp";
    }
    dispatch(jspPage, request, response);
    } protected void dispatch(String jsp, HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException
    {
    if (jsp != null)
    {
    RequestDispatcher rd = getServletContext().getRequestDispatcher(jsp);
    System.out.println("jsp: " +jsp);
    rd.forward(request, response);
    }
    }}
    然后就是index.jsp文件
    如楼上众位所言
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title> Select your preferred portal </title>
    </head>
    <body>
    <h1>  Select please: </h1>
    Your Select is :
    <form action="/TestCsdn/SimpleController" method="POST">
      <select name = "action">
      <option>index</option>
      <option>displayList</option>
       </select>
       <input type ="submit" value="Select"/>
    </form>
    </body>
    </html> 
    然后你再随便写个displayList.jsp  配置一下web.xml文件就可以跑了