为什么我使用了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.
我用的是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.
<%@ 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>
是可以输出内置错误的,
No result defined for action com.test.action.PointAction and result input
这个错误很明显是没有找到结果,如果验证不成功你用个if跳转到原页试试