• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring MVC issue to read data from JSP table

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As part of POC i am facing below challenge:
In HTML table i need to read td data in spring controller using @RequestParam.
Syntax:



could you please suggest how can i read td data(Hello123) in spring controller? If you need any info please let me know.

Thanks,
Rama
 
Sheriff
Posts: 67695
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cannot be done directly. You'll need to create form inputs that contain the data -- "normal" HTML text is not sent to the server as part of a form submission.

Two approaches spring to mind:
  • For each table cell create a corresponding hidden input that contains the same data.
  • Rather than plain text, make each table cell an input control set to read-only, and use CSS to make it look like plain text.
  •  
    Ranch Hand
    Posts: 32
    1
    jQuery Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Bear has it right.  You need inputs.  If you think about it, if they are not inputs how did your user enter them right?  Also, if you have multiple rows in your table then you can actually generate the input names to target an array in a bean on the Spring server.  You do this by use square brackets in your input names, like so.  Imagine there is table markup around these inputs.

    <input type="text" name="firstName[0]" value="Bill"/>  <input type="text" name="lastName[0]" value="Wild"/>

    <input type="text" name="firstName[1]" value="Steve"/>  <input type="text" name="lastName[1]" value="Harvey"/>
     
    Matt Keller
    Ranch Hand
    Posts: 32
    1
    jQuery Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Oops.  My bad.  Got the syntax wrong.  It like this

    <input type="text" name="arrayName[0].firstName" value="Bill"/>
     
    Matt Keller
    Ranch Hand
    Posts: 32
    1
    jQuery Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Evidently this depends on your version of spring as well.  Here is a paste from the following source

    Spring 3 MVC and path attribute and square bracket

    One thing here is worth noting that we haven’t used Spring’s tag to render textboxes. This is because Spring MVC 3 has a unique way of handling path attribute for tag. If we define the textbox as follows:

    <form:input path="contacts[${status.index}].firstname" />
    Then instead of converting it to following HTML code:

    <input name="contacts[0].firstname" />
    <input name="contacts[1].firstname" />
    <input name="contacts[2].firstname" />
    It converts it into following:

    <input name="contacts0.firstname" />
    <input name="contacts1.firstname" />
    <input name="contacts2.firstname" />

    http://viralpatel.net/blogs/spring-mvc-multi-row-submit-java-list/
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic