2010-10-27 9:12:22 org.apache.commons.beanutils.PropertyUtilsBean invokeMethod
严重: Method invocation failed.
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
……
2010-10-27 9:12:22 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.IllegalArgumentException: Cannot invoke com.zhdz.vo.CProduct.setCdate - argument type mismatch
at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778)
at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)由date类型引发的argument type mismatch异常怎么解决?
严重: Method invocation failed.
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
……
2010-10-27 9:12:22 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.IllegalArgumentException: Cannot invoke com.zhdz.vo.CProduct.setCdate - argument type mismatch
at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778)
at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)由date类型引发的argument type mismatch异常怎么解决?
解决方案 »
- java struts2 如何从视频中提取一张照片呢,上传视频后做缩略图用,哪位大哥来帮助帮助我啊。
- 下载了tomcat源码来编译 org.eclipse.jdt.core.compiler 不存在
- spring 配置文件 不能启动加载
- struts2标签问题
- 各位接招: 何谓无状态?
- 我照网上写了一个把小写金额转换成大写的javascript脚本,不过要把100转换成 "壹佰元零拾零元零分",可是我只能转换成"壹佰元零角零分"
- JAR命令问题???请帮忙解决!!!!
- input显示、隐藏兼容性问题
- jsp中怎样做语音跟读对比???急!再线等!
- HTML_<Table>_<tr>_<td></td>中數據過長自動換行問題﹗
- Please help me take a look at this ext coding,Why I could not get data from ds
- JPA怎么关联实体类啊
jsp页面传的是"yyyy-MM-dd"格式的字符串
实现类里用的是
pstm.setTimestamp(3, new Timestamp(cp.getCdate().getTime()));
或
pstm.setDate(3, new java.sql.Date(cp.getCdate().getTime()));
都出现以上异常
public Date getCdate() {
return cdate;
}
public void setCdate(Date cdate) {
this.cdate = cdate;
}
实现类:public boolean doCreate(CProduct cp) throws Exception {
// TODO Auto-generated method stub
boolean flag = false;
String sql="insert into cproduct (ctype,ccount,cdate) values (?,?,?)";
PreparedStatement pstm = this.dbc.getConnection().prepareStatement(sql);
pstm.setString(1, cp.getCtype());
pstm.setInt(2, cp.getCcount());
pstm.setTimestamp(3, new Timestamp(cp.getCdate().getTime()));
int count = pstm.executeUpdate();
if(count>0){
flag=true;
}
return flag;
}
不同类型之间的date需要转换的,省事的方法是写一个convert转换器在代码中自己转换也可以,不过涉及到更低层的一些信息
public String getBrithday() {
return new SimpleDateFormat("yyyy-MM-dd").format(brithday);
}public void setBrithday(String brithday) throws ParseException {
this.brithday = new SimpleDateFormat("yyyy-MM-dd").parse(brithday);
}以后得注意了。