blc*_*ird 5 java jsp tomcat servlets
我有一个带有表单的jsp页面.提交后,它正在调用httpservlet类.但是所有getParamter()操作都返回null.我究竟做错了什么?
JSP
<form action="GatherController" method="post">
<input type='text' name="a"/>
<input type='date' name="b" />
...
<input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
Servlet的
@WebServlet(name = "GatherController", urlPatterns = { "/GatherController" })
public class GatherController extends HttpServlet {
...
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String a = request.getParameter("a");
System.out.println(a);
...
}
}
Run Code Online (Sandbox Code Playgroud)
编辑
- 我正在使用Tomcat v8.0
执行-doPost(...)方法,我得到的输出,System.out.println(a);这是null
我没有足够的声誉来发表评论,所以如果您不介意的话,我会将其作为答案。
请确保您没有在httpServletRequestbefore 上调用其他方法,例如getReader()或getInputStream()。这些调用之后您将无法访问您的帖子参数。
| 归档时间: |
|
| 查看次数: |
1061 次 |
| 最近记录: |