简体   繁体   English

在tomcat 5.x上运行的jsp页面中的getParameter文本字段返回null

[英]null return on getParameter text field in jsp page running on tomcat 5.x

I am getting a weird error of page constantly fluctuating between nullpointerexception to actual execution on every form submit. 我收到一个奇怪的页面错误,该错误在nullpointerexception和每个表单提交的实际执行之间不断波动。 I am writing a simple jsp page and running it on tomcat 5.x server. 我正在编写一个简单的jsp页面,并在tomcat 5.x服务器上运行它。 I am taking data from text field of a form and processing it upon form submit. 我正在从表单的文本字段中获取数据,并在表单提交时对其进行处理。 Here is the code I am trying: 这是我正在尝试的代码:

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
            %>

for this code, page address in address bar is localhost:8080/# or localhost:8080/index.jsp for every form submit. 对于此代码,对于每个表单提交,地址栏中的页面地址均为localhost:8080 /#或localhost:8080 / index.jsp。 I am new to jsp so could not resolve this. 我是jsp的新手,所以无法解决此问题。

It's because the reportName does not set any where for the first time page load! 这是因为reportName并未在首次加载页面时设置任何位置! eg try to navigate 例如尝试导航

localhost:8080/index.jsp?reportName=all 本地主机:8080 / index.jsp?reportName = all

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM