Java Struts:使用逻辑迭代,但不获取更新的列表值
我正在开发一个读取XML的应用程序,这些XML的值在对象consumerXML中设置,该对象在列表中设置,列表将在会话中设置,关键是结果Java Struts:使用逻辑迭代,但不获取更新的列表值,java,struts,Java,Struts,我正在开发一个读取XML的应用程序,这些XML的值在对象consumerXML中设置,该对象在列表中设置,列表将在会话中设置,关键是结果 request.setAttribute("results", list) 流程是这样的 Welcome.JSP,其actionform为consumerxmlActionForm->此处无问题 editxml.jsp即使在这里actionform是consumerxmlActionForm->here列表也会被填充,但不会返回相同的内容。 editxm
request.setAttribute("results", list)
流程是这样的
Welcome.JSP,其actionform为consumerxmlActionForm->此处无问题
editxml.jsp即使在这里actionform是consumerxmlActionForm->here列表也会被填充,但不会返回相同的内容。
editxml.jsp:
jsp正确地显示了列表,当我单击“更改”按钮时,在会话中不会得到结果。有没有其他方法获取该列表
谢谢和问候
Raaghu.K您应该使用表单获取返回操作的值,并使用id并在那里给出VO。然后表格将在行动中可用。你不需要这个课程
<logic:iterate name="monthlyGainLossForm" property="ptcList" id="productTaxCat">
1你并不是在会议上要求什么,而是在请求中——我不确定这是问题中的输入错误还是代码错误。2无论哪种方式,如果要查找表单值,这些都是请求参数,应该在操作表单中。你是说你在提交表单后没有看到你期望的内容?重新提交表单后有问题吗?还有,你不应该使用
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.unicel.vo.ConsumerXML;
import com.unicel.xml.ParseXML;
public class ConsumerXMLAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
String operation = request.getParameter("operation");
ConsumerXMLActionForm actionForm = (ConsumerXMLActionForm) form;
if(operation != null && operation.equals("edit")) {
System.out.println("*** Operation is **** " + operation);
System.out.println("*** actionForm.getOtherGWList() ****" + actionForm.getOtherGWList());
System.out.println("*** From Session *** " + request.getAttribute("results"));
if(actionForm.getOtherGWList() != null) {
for(ConsumerXML consumerXML : actionForm.getOtherGWList()) {
System.out.println("*** Current XML *** " + consumerXML);
}
}
} else {
ParseXML parseXML = new ParseXML();
parseXML.parse();
actionForm.setOtherGWList(parseXML.otherGatewayConsumerList);
request.setAttribute("results", parseXML.otherGatewayConsumerList);
}
return mapping.findForward("success");
}
}
import java.util.ArrayList;
import org.apache.struts.action.ActionForm;
import com.unicel.vo.ConsumerXML;
public class ConsumerXMLActionForm extends ActionForm {
private static final long serialVersionUID = 1L;
private ArrayList<ConsumerXML> otherGWList;
private String operation;
private String beanID;
private String dayTime;
private String nightTime;
private String dayThreshold;
private String nightThreshold;
public String getBeanID() {
return beanID;
}
public void setBeanID(String beanID) {
this.beanID = beanID;
}
public String getDayTime() {
return dayTime;
}
public void setDayTime(String dayTime) {
this.dayTime = dayTime;
}
public String getNightTime() {
return nightTime;
}
public void setNightTime(String nightTime) {
this.nightTime = nightTime;
}
public String getDayThreshold() {
return dayThreshold;
}
public void setDayThreshold(String dayThreshold) {
this.dayThreshold = dayThreshold;
}
public String getNightThreshold() {
return nightThreshold;
}
public void setNightThreshold(String nightThreshold) {
this.nightThreshold = nightThreshold;
}
public ArrayList<ConsumerXML> getOtherGWList() {
return otherGWList;
}
public void setOtherGWList(ArrayList<ConsumerXML> otherGWList) {
this.otherGWList = otherGWList;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
}
<logic:iterate name="monthlyGainLossForm" property="ptcList" id="productTaxCat">