Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ warning "cannot resolve variable" on JSTL

I am writing a web-server using Tomcat. The tech i decided to use is JSTL.

I want to first say that it works, the page displays successfully and everything runs. I do like to get rid of warnings. The warning i get from intelliJ is: "Cannot resolve variable ''", it comes from a JSP page where i have some JSTL code. The jsp page is called from my controller using RequestDispatcher forward function.

request.setAttribute("resultsModel", resultsModel);
request.setAttribute("times", times);
request.setAttribute("emailErr", emailErr);
request.setAttribute("qid", id);
RequestDispatcher view = request.getRequestDispatcher("ShowResults.jsp");
view.forward(request, respone);

The JSP page then uses this variables in a variety of JSTL tags, example from page:

<c:choose>
<%-- When database access was succesfull --%>
<c:when test="${resultsModel != null}">
    <c:choose>
        <%-- When the job ID exists --%>
        <c:when test="${resultsModel.jobEntity != null}">

ect...

The warning is then given on those positions where i try to access resultModel. I tried adding a jsp:useBean tag as such:

<jsp:useBean id="resultsModel" scope="request" type="bgu.bioinf.rnaSequenceSniffer.Model.ResultsModel"/>

But I still get a warning. Any idea? Something i am doing really wrong? Thanks!

like image 336
Matan Drory Avatar asked Dec 14 '14 20:12

Matan Drory


1 Answers

I meet this question too, and really bother me. Today I googled this problem and find no solution. However I used the ModelMap rather than HttpServletRequest.

map.put("info",info);

And no doubt I got this warning,then I changed the method:

map.addAttribute("info",info);

I want to say this way does solve the warning,you can even ctrl + button1 to navigate the bean in the controller. I don't know if this solve the problem in other scenario,But in intellij 2018.1 I just get rid of it.Hope it works for you

like image 78
JXmb Avatar answered Oct 04 '22 19:10

JXmb