我正在尝试将JSP中的文本框中的参数发送到servlet。 出于某种原因,在尝试从servlet获取参数时,我总是得到null。
我的HTML代码是:
<FORM method="POST" action="eimLoggingServlet">
Execution Id <b><INPUT type="text" name="Execution_Id" size="10"> <INPUT
type="submit" name="submit" value="Find log">
</FORM>
我的Servlet代码是:
public class EimLoggingServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String exeId = request.getParameter("Execution_Id");
} catch (Exception e) {
}
}
}
我的Web.xml:
<servlet>
<servlet-name>eimServlet</servlet-name>
<servlet-class>com.viewlinks.eim.monitoring.servlet.EimLoggingServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>eimServlet</servlet-name>
<url-pattern>/eimLoggingServlet</url-pattern>
</servlet-mapping>
exeId始终为空。
答案 0 :(得分:0)
我已将'POST'更改为'GET',显然问题已解决:
JSP:
<FORM method="GET" action="eimLoggingServlet">
Execution Id <b><INPUT type="text" name="Execution_Id" size="10"> <INPUT
type="submit" name="submit" value="Find log">
</FORM>
Servlet:
public class EimLoggingServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String exeId = request.getParameter("Execution_Id");
} catch (Exception e) {
}
}
}