Announcement Announcement Module
No announcement yet.
use hashmap to simplify commandClass? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • use hashmap to simplify commandClass?

    Hi, all

    I just read a post in this forum, the author created a simple bean which only has a hashmap. The hashmap hold all fields in html form, but I can't get it work.

    Here is the command class source:

    import java.util.*;

    public class hashCommand {

    private HashMap formData;

    public hashCommand() {

    formData=new HashMap();



    public void setHashMap(HashMap formData) {



    public HashMap getHashMap() {

    return this.formData;



    I have the following configuration for my dispatcher servlet:

    <bean name="/signonForm.form" class="signonFormController">
    <property name="sessionForm" value="true"/>
    <property name="commandClass" value="hashCommand"/>
    <property name="formView" value="signonForm"/>
    <property name="successView" value="welcome"/>

    My JSP looks like this:

    <spring:bind path="command.formData['username']">
    <tr><td>ID:</td><td><input type=text name=username size=15 value="<c:out value="${status.value}"/>"</td></tr>

    I can't get it work and tomcat complained:

    2005/10/7 下? 05:05:03 org.springframework.web.servlet.FrameworkServlet processRequest
    嚴?的: Could not complete request
    org.apache.jasper.JasperException: Invalid property 'formData[]' of bean class [hashCommand]: Bean property 'formData[]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    at org.apache.jasper.servlet.JspServletWrapper.servic e(
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(
    at org.apache.jasper.servlet.JspServlet.service(JspSe
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at ternalDoFilter(
    at Filter(
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(
    at cessRequest(
    at org.apache.catalina.core.ApplicationDispatcher.doF orward(
    at org.apache.catalina.core.ApplicationDispatcher.for ward(
    at org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi
    at org.springframework.web.servlet.view.AbstractView. render(
    at org.springframework.web.servlet.DispatcherServlet. render(
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(
    at org.springframework.web.servlet.DispatcherServlet. doService(
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(
    at org.springframework.web.servlet.FrameworkServlet.d oGet(
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:689)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at ternalDoFilter(
    at Filter(
    at org.apache.catalina.core.StandardWrapperValve.invo ke(
    at org.apache.catalina.core.StandardContextValve.invo ke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke (
    at org.apache.catalina.core.StandardEngineValve.invok e(
    at org.apache.catalina.connector.CoyoteAdapter.servic e(
    at org.apache.coyote.http11.Http11Processor.process(H
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
    at Socket(
    at ead.runIt(
    at org.apache.tomcat.util.threads.ThreadPool$ControlR
    at Source)


    Is there any successfully story? How can I make it work?


    Vincent Chen

  • #2
    Your setter is called getHashMap, not getFormData.


    • #3
      Take a look at...

      Hi vincent,

      you can take the code from my second post in this thread

      This was copied and pasted from a working application, so it is running.

      Also take a look in the contents of my third post (action-servlet.xml) in the same thread.

      As said, everything is working.
      Last edited by robyn; May 14th, 2006, 07:01 PM.