在Struts中如何處理ActionForm中包含日期型別屬性的情況

sparkguest發表於2003-10-15
JSP定義
<_input name="loginDate" type="text" class="line" id="loginDate">

ActionForm中定義
public class LoginForm extends ActionForm{
private Date loginDate = null;
public Date getLoginDate() {
...

然後執行時報錯
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:324)
at org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:988)
at org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:904)
at org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:932)
at org.apache.struts.util.BeanUtils.populate(BeanUtils.java:509)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:772)
at org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:2061)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:221)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:536)

應該是JSP中的TEXT與ActionForm中的日期型屬性轉換錯誤了,請問大家是如何這種問題的

相關文章