[Struts]java.lang.IllegalArgumentException: array element type mismatch大家帮忙看看

liubincyu 2005-07-21 08:54:14
在struts里面,我用了<html:file> 他在ActionForm中是一个数组,程序没有执行到Action就抛出异常
下面是我的ActionForm代码,麻烦大家提点意见:

public class HomeworkForm extends ActionForm
{

private String date = null;
private org.apache.struts.upload.FormFile[] file = null;
private String content = null;
private String submitDate = null;

/**
* Get date
* @return String
*/
public String getDate()
{
return date;
}

/**
* Set date
* @param <code>String</code>
*/
public void setDate(String d)
{
this.date = d;
}

/**
* Get file
* @return org.apache.struts.upload.FormFile[]
*/
public org.apache.struts.upload.FormFile[] getFile()
{
return file;
}

/**
* Set file
* @param <code>org.apache.struts.upload.FormFile[]</code>
*/
public void setFile(org.apache.struts.upload.FormFile[] f)
{
this.file = f;
}

/**
* Get content
* @return String
*/
public String getContent()
{
return content;
}

/**
* Set content
* @param <code>String</code>
*/
public void setContent(String c)
{
this.content = c;
}

/**
* Get submitDate
* @return String
*/
public String getSubmitDate()
{
return submitDate;
}

/**
* Set submitDate
* @param <code>String</code>
*/
public void setSubmitDate(String s)
{
this.submitDate = s;
}

public void reset(ActionMapping mapping, HttpServletRequest request)
{

// Reset values are provided as samples only. Change as appropriate.

date = null;
file = null;
content = null;
submitDate = null;

}

public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request)
{

ActionErrors errors = new ActionErrors();
// Validate the fields in your form, adding
// adding each error to this.errors as found, e.g.

// if ((field == null) || (field.length() == 0)) {
// errors.add("field", new org.apache.struts.action.ActionError("error.field.required"));
// }
return errors;

}
}
...全文
1124 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangmhsheep 2005-09-08
  • 打赏
  • 举报
回复
呵呵!是form里的值跟jsp里不匹配的问题,array element type mismatch
java.lang.reflect.Array.set(Native Method再查查看了 private org.apache.struts.upload.FormFile[] file = null; 你把你的jsp里对应的标签粘出来看看。可能是这里的问题!
shoulders 2005-07-29
  • 打赏
  • 举报
回复
帮顶。
jiganghao 2005-07-27
  • 打赏
  • 举报
回复
are you sure html:file support file array? the Struts doc site only mentioned rendering ONE file.
liubincyu 2005-07-21
  • 打赏
  • 举报
回复
发生的异常信息为:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.IllegalArgumentException: array element type mismatch
java.lang.reflect.Array.set(Native Method)
org.apache.commons.beanutils.ConvertUtils.convert(ConvertUtils.java:415)
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:983)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

51,412

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧