为什么我使用了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 reportmessage No result defined for action com.test.action.PointAction and result inputdescription The requested resource (No result defined for action com.test.action.PointAction and result input) is not available.

解决方案 »

  1.   

    对了,这是jsp:
    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <%@taglib prefix="s" uri="/struts-tags"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
    </head>
    <body><h3><font color="red">使用“,”将俩个点的坐标分开</font></h3>
    <s:form action="pointConverter"><!-- PointAction中使用List时 -->
    <s:textfield name="point" label="point"></s:textfield>
    <s:textfield name="point" label="point1"></s:textfield>
    <s:textfield name="point" label="point2"></s:textfield>

    <s:textfield name="age" label="age"></s:textfield>
    <s:textfield name="username" label="username"></s:textfield>
    <s:textfield name="date" label="birthday"></s:textfield>
    <s:submit label="submit"></s:submit>

    </s:form>

    </body>
    </html>
      

  2.   

    action配置文件里面配置<result name="input">属性了吗
      

  3.   

    没有,但是我看风中叶的视屏是没有在xml文件中配置input的,但是结果是正确的
      

  4.   

    没有,但是我看风中叶的视屏是没有在xml文件中配置input的,但是结果是正确的 。我用的是eclipse ,而视屏中用的是myeclipse ,想问一下,这个对显示会有影响吗?谢谢!
      

  5.   

    在<result name="intput">/input.jsp</result>
    是可以输出内置错误的,
      

  6.   

    <s:debug></s:debug>可在jsp页面看见堆栈信息,
    No result defined for action com.test.action.PointAction and result input
    这个错误很明显是没有找到结果,如果验证不成功你用个if跳转到原页试试
      

  7.   

    修改struts的日期格式即可,页面只能认yyyy-mm-dd
      

  8.   

    谢谢,学到了,我的解决方法就是在配置文件中加了一个result="input",然后我要的就出来了,呵呵,虽然不是很清楚为什么,但对我目前学习还不构成太大影响,呵呵,谢谢指教。希望以后能够多多跟你们学习。