在JSP页面表单上访问servlet时获取404

时间:2018-08-19 02:25:32

标签: jsp servlets http-status-code-404

我从JSP提交一个调用servlet的表单时得到404。有人可以指出这里有什么问题吗?我确定我在这里错过了什么

我的JSP代码

<form action="objectServer" method="get">
<select name="choice">

    <option value="1" %>1</option>
    <option value="2" %>2</option>
    <option value="3" %>3</option>



</select>
<br />
<input type="submit" value="View the Descrition!" />

我的Servlet代码

public class InfoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse 
response)
 */
 protected void doGet(HttpServletRequest request, HttpServletResponse 
 response)
    throws ServletException, IOException {
    String selected = request.getParameter("choice");
    TestService service = new TestService();
    boolean redirector = service.redirect(selected);
    if(redirector){
        response.sendRedirect("next_page.jsp");
    } else {
        response.sendRedirect("this_page.jsp");
    }
 }
}

WEB.XML

<servlet>
  <servlet-name>InfoServlet</servlet-name>
  <servlet-class>org.storyapp.servlet.InfoServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>InfoServlet</servlet-name>
<url-pattern>/objectServer</url-pattern>
</servlet-mapping>

0 个答案:

没有答案