Announcement Announcement Module
Collapse
No announcement yet.
Strange JSP Behavior with Spring Taglib Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strange JSP Behavior with Spring Taglib

    I'm getting really strange behavior from my application. I have a JSP that is generated with a few Spring form tags:

    Code:
      <table width="95%" bgcolor="f8f8ff" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right" width="20%">ID:</td>
            <td width="20%">
               <form:input path="dbId"/> 
            </td>
            <td width="60%">
              <form:errors path="dbId" cssClass="error"/>
            </td>
        </tr>
        <tr>
          <td align="right" width="20%">New Name:</td>
            <td width="20%">
              <form:input path="name"/>
            </td>
            <td width="60%">
              <form:errors path="name" cssClass="error"/>
            </td>
        </tr>
        <tr>
          <td align="right" width="20%">New Description:</td>
            <td width="20%">
              <form:input path="description" />
            </td>
            <td width="60%">
              <form:errors path="description" cssClass="error"/>
            </td>
        </tr>
      </table>
    This should generate three fields linked to the associated command: id, name, and description. However, when I hit the application on the web, the HTML returned is incorrect:

    Code:
      
    <table width="95%" bgcolor="f8f8ff" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right" width="20%">ID:</td>
            <td width="20%">
               <input id="dbId" name="dbId" type="text" value="2"/> 
            </td>
            <td width="60%">
              
            </td>
    
        </tr>
        <tr>
          <td align="right" width="20%">New Name:</td>
            <td width="20%">
              <input id="dbId" name="dbId" type="text" value="2"/>
            </td>
            <td width="60%">
              
            </td>
    
        </tr>
        <tr>
          <td align="right" width="20%">New Description:</td>
            <td width="20%">
              <input id="dbId" name="dbId" type="text" value="2"/>
            </td>
            <td width="60%">
              
            </td>
    
        </tr>
      </table>
    As you can see, the dbId field gets repeated three times, and the "name" and "description" form input tags are lost somewhere. Although it is not represented here, the same happens with the error tags.

    Now, if I add a maxlength attribute to the second input tag, it gets rendered correctly:

    Code:
    <table width="95%" bgcolor="f8f8ff" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right" width="20%">ID:</td>
            <td width="20%">
               <form:input path="dbId"/> 
            </td>
            <td width="60%">
              <form:errors path="dbId" cssClass="error"/>
            </td>
        </tr>
        <tr>
          <td align="right" width="20%">New Name:</td>
            <td width="20%">
              <form:input path="name" maxlength="1"/>
            </td>
            <td width="60%">
              <form:errors path="name" cssClass="error"/>
            </td>
        </tr>
        <tr>
          <td align="right" width="20%">New Description:</td>
            <td width="20%">
              <form:input path="description" />
            </td>
            <td width="60%">
              <form:errors path="description" cssClass="error"/>
            </td>
        </tr>
      </table>
    ... Compiles to ...

    Code:
      
    <table width="95%" bgcolor="f8f8ff" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right" width="20%">ID:</td>
            <td width="20%">
               <input id="dbId" name="dbId" type="text" value="2"/> 
            </td>
            <td width="60%">
              
            </td>
    
        </tr>
        <tr>
          <td align="right" width="20%">New Name:</td>
            <td width="20%">
              <input id="name" name="name" type="text" value="tester" maxlength="1"/>
            </td>
            <td width="60%">
              
            </td>
    
        </tr>
        <tr>
          <td align="right" width="20%">New Description:</td>
            <td width="20%">
              <input id="dbId" name="dbId" type="text" value="2"/>
            </td>
            <td width="60%">
              
            </td>
    
        </tr>
      </table>
    ... but again, the third input field is a repeat of the first. The "description" input field is lost.

    This is Spring 2.5 running on Tomcat 6.0.18, Java 1.6.0_07

  • #2
    Have you set the <form:form commandName="yourCommandName"> tag aswell?

    Comment


    • #3
      Originally posted by noon View Post
      Have you set the <form:form commandName="yourCommandName"> tag aswell?
      Yes. That is set.

      Comment

      Working...
      X