How to use multiple buttons (one on each line) for JSP page using Struts2

前端 未结 1 1471
鱼传尺愫
鱼传尺愫 2020-12-12 02:24

I don\'t really know how to title my question, but I have a JSP page with a table displaying elements from a database, and I want to have a button for each row to either del

相关标签:
1条回答
  • 2020-12-12 03:00

    I'm not sure why you have a table nested for just the buttons... perhaps it's for layout. I would suggest making each of your top-level have a form with another attribute identifying the row, and two submit buttons.

    e.g. something like this (untested)

    <s:form theme="simple">
        <s:hidden key="rowID" />
        <s:submit action="remove" value="Remove"/>
        <s:submit action="edit" value="Edit"/>
    </s:form>
    

    You can have a single form with multiple actions for each. Just put something in the row that uniquely identifies the row that you'll be acting upon.

    So, what'll happen is that when this is submitted, the rowID will be included in the request and sent to your specific action as a parameter to the setter (setRowID()). Just pick something from whatever your original data is that uniquely identifies it.

    0 讨论(0)
提交回复
热议问题