JiveJdon Community Forums
在线164人   首页   主题表   培训咨询   标签   查搜   注册    登陆 RSS
首页 » 论坛 » 语言平台技术讨论
???en_US.forumThreadPrev.name??? 上一主题
RSS google yahoo 365Key网摘 CSDN网摘 添加到百度搜藏 POCO网摘 新浪ViVi QQ网摘
???en_US.forumThreadNext.name??? 下一主题
Go 共有 0 回复(1页) 阅读233次
 发表新帖子   回复该主题贴
hechenhui1983



发表文章:
注册时间: 2008年12月09日
悄悄话
个人博客
在线? 当前离线
我要关注该作者发言
Struts2日期类型转换问题??? 2009年06月30日 09:50 收藏关注本主题 到本帖网址 加入本帖到收藏夹 请用鼠标选择需要回复的文字再点按本回复键 回复该主题
标签
我在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配置也加上了,还是同样的错误。。

标签
共有 0 回复(1页) Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
正在读取,请等待...
查询本论坛内 回复超过的热门帖子
标题
 
粗体: [b]文本[/b] 斜体: [i]文本[/i] 下划线 [u]文本[/u] 插入网上的图片 [img]http://wwww.xxxx.com/img.ext[/img] 插入代码 [code]程序代码[/code]  插入url链接 [url]http://url[/url] / [url=http://url]URL加下滑线[/url] 上传图片 word文档 Txt等附件
内容
  提交时自动拷贝以上内容到剪贴板 Ctrl+V可取出;提问题前先查询标签列表

使用帮助 手机m.jdon.com RSS add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的软件架构社区 推荐FireFox或Chrome快速浏览本站
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-10 jdon.com

anti spam