[英]jsp request.getParameter in if condition
I have to call function based on the request.getParameter("name")
value.我必须根据request.getParameter("name")
值调用 function 。 If I use the following code I am getting error:如果我使用以下代码,我会收到错误:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 82 in the jsp file: alert.jsp
url cannot be resolved to a type
This is the code I used:这是我使用的代码:
if(request.getParameter("name")==null)
{
test=0;
out.println("user:"+user);
String url[][]=mon.fun(user);
}
else{
test=1; out.println("ser:"+ServerName+" "+user);
String url[][]=mon.function(ServerName,user);
}
for(int i=0;url!=null&&i<url.length;i++){
out.println(url[i][0]);
}
But if i call those functions separately that is not inside the if condition, I am able to access the url values.但是,如果我单独调用那些不在 if 条件内的函数,我可以访问 url 值。
Where am I going wrong?我哪里错了?
Put放
String[][] url;
before your if
clause, and set its value inside the blocks with:在你的if
子句之前,并在块内设置它的值:
url = ...;
Variable go out of scope as soon as the block it's declared in is closed.一旦声明的块关闭,变量 go 就从 scope 中取出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.