我收到一个奇怪的错误,页面在每个表单提交的空指针异常和实际执行之间不断波动。我正在编写一个简单的 jsp 页面并在 tomcat 5.x 服务器上运行它。我正在从表单的文本字段获取数据并在表单提交时对其进行处理。这是我正在尝试的代码:
form id="mainForm" method=POST action="index.jsp">
<input type="text" name="reportName" size=20>
<a class="btnBlue btnBlueRight" href="#" onclick="document.getElementById('mainForm').submit();" >
<%
if(request.getParameter("reportName")!=null){
//do things
else
//print message
%>
对于此代码,对于每个表单提交,地址栏中的页面地址是 localhost:8080/# 或 localhost:8080/index.jsp。我是 jsp 新手,所以无法解决这个问题。
最佳答案
这是因为reportName没有设置任何第一次页面加载的位置!例如尝试导航
localhost:8080/index.jsp?reportName=all
关于java - 在 tomcat 5.x 上运行的 jsp 页面中 getParameter 文本字段返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14147128/