日期:2014-05-18  浏览次数:20655 次

关于Struts2类型转化的问题
为什么我使用了Struts的表单,但是为什么当我的输入不符合时它没有执行内置的校验呢?很是不解。。。
我用的是eclipse 和tomcat 7.0
jar包

比如:Invalid field value for field "birthday". 这样的信息,这是由Struts2自身的校验给出来的信息,默认的情况下,如果遇到类型转化失败的问题,struts2会自动添加一条错误信息,使用addFieldError()添加一条错误信息。

但是为什么我的没有出现这个,而是直接出了404(注明但输入的数值都没问题是页面是正常跳转的)
错误如下:(由于网速较慢,截图无法上传,抱歉)
HTTP Status 404 - No result defined for action com.test.action.PointAction and result input

--------------------------------------------

type Status report

message No result defined for action com.test.action.PointAction and result input

description The requested resource (No result defined for action com.test.action.PointAction and result input) is not available.

------解决方案--------------------
action配置文件里面配置<result name="input">属性了吗
------解决方案--------------------
你打堆栈看看么!
------解决方案--------------------
<s:debug></s:debug>可在jsp页面看见堆栈信息,
No result defined for action com.test.action.PointAction and result input
这个错误很明显是没有找到结果,如果验证不成功你用个if跳转到原页试试
------解决方案--------------------
修改struts的日期格式即可,页面只能认yyyy-mm-dd