gpt4 book ai didi

java - if条件下的jsp request.getParameter

转载 作者:行者123 更新时间:2023-11-29 03:55:26 24 4
gpt4 key购买 nike

我必须根据 request.getParameter("name") 值调用函数。如果我使用以下代码,则会出现错误:

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

这是我使用的代码:

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]);
}

但是如果我单独调用那些不在 if 条件内的函数,我就能够访问 url 值。

我哪里错了?

最佳答案

String[][] url;

您的if 子句之前,并在 block 内设置其值:

url = ...;

一旦在其中声明的 block 关闭,变量就会超出范围。

关于java - if条件下的jsp request.getParameter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6674563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com