简体   繁体   English

为什么会出现错误“方法...类型未定义...”?

[英]Why do I get an error “The method … is undefined for the type…”?

I've build a method which takes strings as input parameter. 我建立了一个将字符串作为输入参数的方法。 In my index.jsp page, I retrieve a GET-variable from the URL using request.getParameter() . index.jsp页面中,我使用request.getParameter()从URL检索GET变量。 Now, I want to call the aforementioned method on this string, but I get a compiler error saying: 现在,我想在此字符串上调用上述方法,但出现编译器错误,提示:

The method <method name> (String) is undefined for the type __2F_<webapp name>_2F_src_2F_main_2F_webapp_2F_index_2E_jsp ". 对于类型__2F_<webapp name>_2F_src_2F_main_2F_webapp_2F_index_2E_jsp “,未定义方法<method name> (String)。

Does anyone know why I get this error and how I can get rid of it. 有谁知道我为什么得到这个错误以及如何摆脱它。 Any help is greatly appreciated! 任何帮助是极大的赞赏!

My code is rather lengthy, but I think this is relevant code: 我的代码很长,但是我认为这是相关的代码:

categorie = request.getParameter("categorie");

if (categorie.equals("")) {
    categorie = "Category;";
}

ArrayList<String> categorieen = queryCategories(categorie);

You are calling ArrayList<String> categorieen = queryCategories(categorie); 您正在调用ArrayList<String> categorieen = queryCategories(categorie); and you did not define queryCategories method. 并且您没有定义queryCategories方法。 Since the JSP page is compiled into a big servlet class, it tries to locate queryCategories method as member of that class and it could not find it. 由于JSP页面已编译为一个大型Servlet类,因此它尝试将queryCategories方法定位为该类的成员,但找不到该方法。

Very little information. 信息很少。 Where is your app deployed? 您的应用程序部署在哪里? From what I gather, it seems you either haven't restarted the deployed app or have not replaced the changed class file and haven't set some sort of "development mode" on wherein you don't require a restart for a Jsp modification. 据我所知,您似乎没有重启过部署的应用程序,或者没有替换过更改后的类文件,也没有设置某种“开发模式”,因此您不需要为Jsp修改而重启。

Just replace the .jsp and JSP_NAME.class file. 只需替换.jspJSP_NAME.class文件。

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

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