Hello, friends! Please tell me in the next question. I work with Struts2

There is an Action that processes requests.

public class ComputerAction extends ActionSupport { private List<CompBean> ComputerList; // Хранит список всех компьютеров private String id;// Запоминает ID текущего компьютера @Override public String execute() throws Exception { HibernateComputerDao daoC = new HibernateComputerDao(); ComputerList = daoC.loadAllComputer(); return SUCCESS; } // get/set metgods } 

And there is also a JSP page that lists all computers.

 <s:iterator value="ComputerList" status="status" > <tr> <td> <s:property value="id"/> </td> <s:form action="computer" method="POST"> **<s:hidden name="id" value="#ComputerList.id" />** <s:submit method="deleteComputer" class="link" value="Удалить"></s:submit> </s:form> </td> </tr> </s:iterator> 

<s:hidden name="id" value="#ComputerList.id" /> in the id variable, I want to put the value #ComputerList.id , but nothing comes out. Tell me what to do.

  • value = "# ComputerList.CompBean.id" - Gorets
  • Unfortunately, it turns out the following: id = # ComputerList.CompBean.id. That is, not the value of the string, but the string itself is recorded ... - comedy19293

1 answer 1

In the hidden field you need to write the value from the iterator. If the iterator is placed on the list of objects that have an id attribute, then you can safely enter this value directly into the value field.

 <s:hidden name="id" value="%{id}" />