我想从表单中填充字符串列表。
我的表单bean:
public class TaskForm extends ActionForm{
List<String> task = new ArrayList<String>();
public List<String> getTask() {
return task;
}
public void setTask(List<String> task) {
this.task=task;
}
}
我的jsp:
while (it.hasNext()) {
<textarea class="SubTaskTextArea_Style" id="task" name="task"></textarea></td>
}
struts 配置:
<form-beans>
<form-bean name="TaskForm" type="controller.form.TaskForm" />
</form-beans>
<action-mappings>
<action path="/TaskAction" type="task.action.TaskAction" name="TaskForm">
</action-mappings>
情况是textarea
可以是任意数量,我想将 textarea 中的字符串填充到formbean
.
但它给出了以下错误:
javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1099)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:924)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:729)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1097)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
有人知道吗?