0

When running my code on Tomcat, I receive the following error:

javax.el.PropertyNotFoundException: Property 'HelpGroupItems' not found on type com.aais.helpguides.HelpGuide.

I have checked the HelpGuide.java file to make sure I have the HelpGroupItems getter/setter methods defined correctly. I have checked both jsp files as well for any misspelling of the name. When showForm=true, the /updateForm will show up, but it is only when showForm is false or I hit the submit button from the updateForm do I run into this error. Any help would be appreciated.

HelpGuideController.java

package com.aais.helpguides;

import com.aais.helpguides.HelpGuide;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; 
import org.springframework.web.servlet.ModelAndView;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RequestMethod; 
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.HashMap;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.SQLException;


@Controller
@RequestMapping("/")
public class HelpGuideController 
{
    private ArrayList<String> helpGroupNames;
    private ArrayList<String> helpGroupDescriptions;
    private HashMap<String,ArrayList<String>> model;


    @RequestMapping("/helpgroup")
    public ModelAndView getUpdateForm(@ModelAttribute("helpguide") HelpGuide helpguide, BindingResult result, @RequestParam("showForm") boolean showForm)
    {
        ArrayList<String> helpGroupNames = new ArrayList<String>();
        helpGroupNames.add("Help Contents");
        helpGroupNames.add("Affiliate Guide");
        ArrayList<String> helpGroupDescriptions = new ArrayList<String>();
        helpGroupDescriptions.add("Items related to Help Contents");
        helpGroupDescriptions.add("Items related to Affiliate Guide");
        HashMap<String, ArrayList<String>> model = new HashMap<String, ArrayList<String>>();
        model.put("helpGroupNames", helpGroupNames);
        model.put("helpGroupDescriptions", helpGroupDescriptions); 
        helpguide.setDescription("Items related to Help Contents");
        helpguide.setHelpGroupItems("Help Contents");
        if(showForm!=false)
        {
            return new ModelAndView("helpguides/updateForm", "model", model);
        }
        else 
        {
            /*final String dbUserName = "AAISdirectHelpUser";
            final String dbPassword = "Wr6Vaswa";
            final String dbURL = "jdbc:sqlserver://127.0.0.1;database=AAISdirectHelp";

            try
            {
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                Connection conn = DriverManager.getConnection(dbURL, dbUserName, dbPassword);

                Statement stmnt = conn.createStatement();
                Statement stmnt2 = conn.createStatement();
                String querySQL ="SELECT Name, Description FROM config.HelpGroup";
                ResultSet results = stmnt.executeQuery(querySQL);
                while(results.next())
                {
                    System.out.println(results.getString("Name"));
                }
            }
            catch(SQLException e1)
            {
                e1.printStackTrace();
            }
            catch(ClassNotFoundException e2)
            {
                e2.printStackTrace();
            }
            catch(Exception e3)
            {
                e3.printStackTrace();
            } */
            return new ModelAndView("helpguides/showHelpGroups", "model", model);
        }

    }

    @RequestMapping("/showDetails")
    public ModelAndView showDetails(@ModelAttribute("helpguide") HelpGuide helpguide, BindingResult result)
    {
        System.out.println("HelpGroupNames: " + helpguide.getHelpGroupItems());

        System.out.println("HelpGroupDescription: " + helpguide.getDescription());

        return new ModelAndView("helpguides/showHelpGroups", "helpguide", helpguide);
    }


    public ArrayList<String> getHelpGroupName()
    {
        return helpGroupNames;
    }

    public void setHelpGroupName(ArrayList<String> helpGroupNames)
    {
        this.helpGroupNames = helpGroupNames;
    }
    public ArrayList<String> getHelpGroupDescription()
    {
        return helpGroupDescriptions;
    }
    public void setHelpGroupDescription(ArrayList<String> helpGroupDescriptions)
    {
        this.helpGroupDescriptions = helpGroupDescriptions;
    }
    public HashMap<String, ArrayList<String>> getModel()
    {
        return model;
    }
    public void setModel(HashMap<String,ArrayList<String>> model)
    {
        this.model = model;
    }

    /*@RequestMapping(value="/helpgroup" , method = RequestMethod.GET)
    public String updateHelpGroupForm(Model model)
    {
        model.addAttribute("message", "Welcome to the AAISdirect Support Page");
        model.addAttribute(new HelpGuide());
        return "helpguides/HelpGroup";
    }*/
    /*@RequestMapping(value="/helpcenter" , method=RequestMethod.POST)
    public String update(@Valid HelpGuide helpguide, BindingResult result) 
    {
        if (result.hasErrors()) 
        {
            return "helpguides/updateForm";
        }
        this.helpguides.put(helpguide.getName(), helpguide);
        return "redirect:/helpcenter/" + helpguide.getName();
    }*/

    @RequestMapping(value="/helpgroup/helpcontents", method = RequestMethod.GET)
    public String getHelpContents(Model model)
    {
        model.addAttribute("message", "Welcome to the Help Contents Support Page");
        return "helpguides/showHelpContents";

    }

    @RequestMapping(value="/helpgroup/affiliateguide" , method = RequestMethod.GET)
    public String showAffiliateGuideHelp(Model model)
    {
        model.addAttribute("message", "Welcome to the Affiliate Guide Support Page");
        return "helpguides/showHelpContents";
    }
}

StackTrace

org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/helpguides/showHelpGroups.jsp at line 21

18:             <td>Description: </td>
19:         </tr>
20:         <tr>
21:             <td>${helpguide.HelpGroupItems}</td>
22:             <td><a href="helpgroup/affiliateguide">${helpguide.description}</a></td>    
23:         </tr>
24:         <tr>

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
            org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
            org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
            org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
            org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
            org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
            org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
            org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
            org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
            org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
            org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
            org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
            org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        root cause

    javax.el.PropertyNotFoundException: Property 'HelpGroupItems' not found on type com.aais.helpguides.HelpGuide
        javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:229)
        javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:206)
        javax.el.BeanELResolver.property(BeanELResolver.java:317)
        javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
        org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
        org.apache.el.parser.AstValue.getValue(AstValue.java:182)
        org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)

    org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:967)
        org.apache.jsp.WEB_002dINF.views.helpguides.showHelpGroups_jsp._jspService(showHelpGroups_jsp.java:88)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)

HepGuide.java

package com.aais.helpguides;

public class HelpGuide
{
    private String helpGroupItems;
    private String helpSectionItems;
    private String affiliateGuideItems;
    private String description;
    private long helpGroupID;

public long getHelpGroupId()
{
    return helpGroupID;
}
public void setHelpGroupId(long helpGroupID)
{
    this.helpGroupID = helpGroupID;
}
public String getHelpGroupItems()
{
    return helpGroupItems;
}
public void setHelpGroupItems(String helpGroupItems)
{
    this.helpGroupItems = helpGroupItems;
}
public String getHelpContentItems()
{
    return helpSectionItems;
}
public void setHelpContentItems(String helpSectionItems)
{
    this.helpSectionItems = helpSectionItems;
}
public String getAffiliateGuideItems()
{
    return affiliateGuideItems;
}
public void setAffiliateGuideItems(String affiliateGuideItems)
{
    this.affiliateGuideItems = affiliateGuideItems;
}
public String getDescription()
{
    return description;
}
public void setDescription(String description)
{
    this.description = description;
}
}

showHelpGroup.jsp

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ page import="java.io.*,java.util.*,java.sql.*" %>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<html>
<head><title>AAISdirect Help Center</title></head>
<body>

<h2> ${message} </h2>
    <table style="width:500px">
    <tr>
            <td>Name: </td>
            <td>Description: </td>
        </tr>
        <tr>
            <td>${helpguide.helpGroupItems}</td>
            <td><a href="helpgroup/affiliateguide">${helpguide.description}</a></td>    
        </tr>
        <tr>
            <!-- <td>${model.helpGroupNames}</td> -->
            <!-- <td>${model.helpGroupDescriptions}</td> -->
        </tr>       
    </table>

</body>
</html>

updateForm.jsp

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<html>
<head>
</head>
    <title>Update Help Group</title>
    <link rel="stylesheet" href="<c:url value="/resources/blueprint/screen.css" />" type="text/css" media="screen, projection">
    <link rel="stylesheet" href="<c:url value="/resources/blueprint/print.css" />" type="text/css" media="print">

    <form:form method="post" action="showDetails"  modelAttribute="helpguide">
        <table style="width:500px">
            <tr>
                <td>Help Groups</td>
                <td><form:input path="helpGroupItems"/>
                <td><form:input path="description"/>
                <%-- <td><form:select path="name" items="${model.helpGroupNames}"/> --%>
                <td><form:select path="description" items="${model.helpGroupDescriptions}"/>
                <td><input type="submit" value="Submit"/></td>  
            </tr>
        </table>
    </form:form>        
</body>
</html>
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
atsprink
  • 5
  • 5

1 Answers1

0

It should be

<td>${helpguide.helpGroupItems}</td>

Start with lowercase the property, as your class is

public class HelpGuide
{
    private String helpGroupItems;
Koitoer
  • 18,778
  • 7
  • 63
  • 86