我的jsp页面web/jsppages/addreport.jsp
<%if(request.getParameter("addReport") != null){ %>
<jsp:forward page="/addReportGuiControlServlet" />
<%} %>
<form action="addReport.jsp" name="myform" method="POST">
<h4 class="desc">How many people are there in the queue?</h4>
<div>
<input class="addreport" type="checkbox" id="isLast" name="isLast">
<label class="desc">I'm the last of the queue</label>
</div>
<div class="container1">
<input class="addreport" type="text" name="queueLen" id="queueLen" autocomplete="off">
</div>
<div class="container2">
<input class="addreport" type="submit" name="addReport" value="Add Report">
</div>
</form>
我的servlet
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
RequestDispatcher rd = request.getRequestDispatcher("/jspPages/addReport.jsp");
rd.forward(request, response);
}
我的web.xml
<servlet>
<servlet-name>AddReportGuiControlServlet</servlet-name>
<servlet-class>logic.boundary.web.controlgrafico.AddReportGuiControlServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AddReportGuiControlServlet</servlet-name>
<url-pattern>/addReportGuiControlServlet</url-pattern>
</servlet-mapping>
错误的结果是一个无限循环。我认为问题出在参数“addreport”上,因为在servlet中我试图打印它,结果是!=null,但我不知道如何设置此值。
1条答案
按热度按时间6ie5vjzr1#
我通过在servlet的url中添加一个参数来解决这个问题:
然后我将控件插入jsp:
这是因为参数addreport保持不为null,然后由servlet转发