0

我正在尝试在我的应用程序中实现分页。目前,我试图在实现导航之前只查看第一条记录,但是我遇到了一个错误,我不确定我的配置是否准确。我实现了 PagedListHolder 但我不确定是否需要为此定义一个类似的泛型类。

我收到以下错误:

错误:

org.springframework.beans.NotReadablePropertyException: Invalid property 'crimeRecNo' of bean class [org.springframework.beans.support.PagedListHolder]: Bean property 'crimeRecNo' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

监控类

public class Monitoring {

    private int monitoringId;
    private int socialSecurityNumber;
    private int monitoringTypeId;
    private String monitoringStDate;
    private String monitoringEndDate;
    private int crimeRecNo;
    /**
     * 
     */
    public Monitoring() {

    }

//setters and getters 
public void setSocialSecurityNumber(int socialSecurityNumber) {
        this.socialSecurityNumber = socialSecurityNumber;
    }

public int getSocialSecurityNumber() {
        return socialSecurityNumber;
    }

控制器

@RequestMapping(value = "monitoringList.htm", method = RequestMethod.GET)
        public ModelAndView handleMonitoring(@RequestParam(value="crimeRecNo")byte[] crimeRecNo, Model model,
                @ModelAttribute Monitoring monitoring, BindingResult result,ModelMap m) throws Exception {

            String  dcryCrimeRecNo = StringSecurity.decrypt(crimeRecNo);
            int i_crimeRecNo = Integer.parseInt(dcryCrimeRecNo);


            myMonitoringTypeList.put("monitoringTypeList",this.monitoringTypeManager.getListOfMonitoringType());

            model.addAttribute("monitoringType",myMonitoringTypeList);


            PagedListHolder<Monitoring> citizenPage = new PagedListHolder<Monitoring>(this.monitoringManager.getMonitoringRecordsByCrimeRecNo(i_crimeRecNo));

            //citizenPage.setPageSize(0);   

            citizenPage.setPage(0);



            model.addAttribute("crimeRecNo", i_crimeRecNo);
            model.addAttribute("monitoring", citizenPage);



            return new ModelAndView("monitoringList"); 
        }

JSP

  </head>
<body>
    <form:form id="monitoringList" name="monitoringList" commandName="monitoring">
    <h3>Monitoring For Criminals Victims/Wittiness</h3>
        <h3>Crime Record - ${crimeRecNo}</h3>       

        <div><button id="action" onclick="submitPage('${pageContext.request.contextPath}/monitoringList.htm');" type="button">Create Monitoring Records</button></div>



        <input type="hidden" id="crimeRecNo" value="${monitoring.crimeRecNo}"/>

        <div id="victims">
        <h3>Victims</h3>

            <div id="citizen_row">          

            <label class="name"></label>

            <form:input type="hidden" name="socialSecurityNumber" path="socialSecurityNumber" value="${monitoring.socialSecurityNumber}"/>

            <table border="1">          

            <tr>

            <td><form:input type="hidden" path="crimeRecNo" name = "crimeRecNo" value="${monitoring.crimeRecNo}"/>
            <canvas id="photoCvs${citizen.socialSecurityNumber}" class="canvas" height="200" width="200"></canvas></td>
            <td><label>Start Date : </label><form:input name= "monitoringStDate" path="monitoringStDate" id="monitoringStDate" value="${monitoring.monitoringStDate}"/></td>
            <td><label>End Date : </label><form:input name="monitoringEndDate" path="monitoringEndDate" id="monitoringEndDate" value="${monitoring.monitoringEndDate}"/></td>
            <td>
            <label>Monitoring Type : </label>
                <form:select path="monitoringTypeId" name="monitoringTypeId" id="monitoringTypeId" title="Monitoring Type">
                    <form:options items="${monitoringType.monitoringTypeList}" itemValue="monitoringTypeId" itemLabel="monitoringTypeDesc" />
                </form:select>              
            </td>
            </tr>

            </table>                
            </div>

        </div>

        <hr>

        <div id="footer"></div>
    </form:form>
</body>

错误日志

 org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/monitoringList.jsp at line 128

125:            
126:            <label class="name"></label>
127:            
128:            <form:input type="hidden" name="socialSecurityNumber" path="socialSecurityNumber" value="${monitoring.socialSecurityNumber}"/>
129:            
130:            <table border="1">          
131:            


Stacktrace:
    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:728)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

root cause

javax.el.PropertyNotFoundException: Property 'socialSecurityNumber' not found on type org.springframework.beans.support.PagedListHolder
    javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237)
    javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214)
    javax.el.BeanELResolver.property(BeanELResolver.java:325)
    javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
    org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
    org.apache.el.parser.AstValue.getValue(AstValue.java:183)
    org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
    org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:1026)
    org.apache.jsp.WEB_002dINF.jsp.monitoringList_jsp._jspx_meth_form_005finput_005f0(monitoringList_jsp.java:376)
    org.apache.jsp.WEB_002dINF.jsp.monitoringList_jsp._jspx_meth_form_005fform_005f0(monitoringList_jsp.java:301)
    org.apache.jsp.WEB_002dINF.jsp.monitoringList_jsp._jspService(monitoringList_jsp.java:204)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    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:728)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
4

1 回答 1

0

您正在使用 2 个模型

model.addAttribute("crimeRecNo", i_crimeRecNo);

return new ModelAndView("monitoringList","monitoring",citizenPage); 

JSP 试图从您的模型中访问“crimeRecNo”,但您的模型已经是没有此属性的“citizenPage”,您可以像这样开发它

model.addAttribute("crimeRecNo", i_crimeRecNo);
model.addAttribute("monitoring", citizenPage);
return "monitoringList";

您也在使用更新 1

<form:form id="monitoringList" name="monitoringList" commandName="monitoring">

然后

<form:input type="hidden" path="crimeRecNo" name = "crimeRecNo" value="${crimeRecNo}"/> 

所以它在citizenPage的“monitoring”中寻找“crimeRecNo”

于 2013-05-01T06:22:02.477 回答