how to display data obtained from dao in jsp

后端 未结 1 1708
余生分开走
余生分开走 2021-01-17 06:21

in jsp


        <         
相关标签:
1条回答
  • 2021-01-17 06:52

    I spot several mistakes:

    Here,

    <c:forEach items="${resultList}" var="resultList"> 
    

    You're overriding the list value with the value of the list item everytime. Don't do that. Give the var an unique variable name. The entity name is the most straightforward choice.

    <c:forEach items="${resultList}" var="project"> 
    

    Note that I'd personally also rename the nothing-saying resultList to a more self-explaining projects.


    And here,

    <tr class="bg-row1">
        <c:forEach items="${resultList}" var="project"> 
    

    the flow is wrong. You should print a new row inside each loop. Swap them.

    <c:forEach items="${resultList}" var="project"> 
        <tr class="bg-row1">
    

    And here,

    ${resultList.Projid}
    ${resultList.Projname}
    ${resultList.Cost}
    ${resultList.Manager}
    

    the property names must start with lowercase (and fix the item name to be the same as in var).

    ${project.projid}
    ${project.projname}
    ${project.cost}
    ${project.manager}
    

    Note that I'd personally also get rid of proj prefix in some property names.


    And finally you're forgotten a closing </c:forEach>.

        </tr>
    </c:forEach>
    

    Unrelated to the concrete problem, your JDBC code is sensitive to SQL injection attacks and is leaking resources. Fix it as well.

    0 讨论(0)
提交回复
热议问题