Struts2日期类型转换问题???

09-06-30 hechenhui1983
我在jsp文本框中输入日期格式的数据,在Action中使用Date类型接收时报错,如果不输入日期(使日期为空)或在Action中使用String类型来接收就不会报错,这是为什么???错误提示是找不到返回结果,这个错误和日期字段有关系吗,难道只是配置文件写错了???如果和日期类型转换有关系应该怎么改???

错误:

11:44:40,640 ERROR Dispatcher:515 - Could not find action or result

No result defined for action www.account.people.struts.TestAction and result input - action - file:/E:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/account/WEB-INF/classes/config/struts/people/people-struts.xml:23:56

at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:345)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)

at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48) ....

代码如下:

jsp代码:

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Insert title here </title>

</head>

<body>

<form action=" <%=request.getContextPath()%>/test/toGo.shtml" method="post">

str: <input type="text" name="str" id = "str">

time: <input type="text" name="timee" id="timee">

<input type="submit" value="提交">

</form> </body>

</html>

Action代码:

public class TestAction extends BaseAction {

private Date timee;

private String str;

private String times;

public String toGo(){

System.out.println(times);

return super.SUCCESS;

}

public String getStr() {

return str;

}

public void setStr(String str) {

this.str = str;

}

public Date getTimee() {

return timee;

}

public void setTimee(Date timee) {

this.timee = timee;

}

public String getTimes() {

return times;

}

public void setTimes(String times) {

this.times = times;

}

}

struts2配置文件:

<package name="test" namespace="/test" extends="struts-default">

<action name="toGo" class="testAction" method="toGo">

<!-- <result name="input">/index.jsp </result> -->

<result name="success">/index.jsp </result>

</action>

</package>

补充:

1.我后来把jsp使用struts2的标签重新写了一边,日期也使用了struts2的日期控件,提交后还是报同样的错误。。

2.按网上的一些说法我也添加了Date类型转换类,xwork-conversion.properties配置也加上了,还是同样的错误。。

2
猜你喜欢