关于Validation的错误,请大家帮忙看看
jsp页面如下:
<%@ taglib uri="struts/bean-el" prefix="bean" %>
<%@ taglib uri="struts/html-el" prefix="html" %>
<%@ taglib uri="struts/logic-el" prefix="logic" %>
<%@ taglib uri="jstl/c" prefix="c" %>
<html>
<head>
<link href="<html:rewrite page="/rr.css" />" rel="stylesheet" type="text/css">
<center><title><bean:message key="title.devicestatus.deviceStatusForm"/></title></center>
</head>
<body><center>
<c:choose>
<c:when test="${DeviceActionForm.map.dispatch == 'insert'}">
<h1><bean:message key="title.devicestatus.insertDeviceStatusForm"/></h1>
</c:when>
<c:otherwise>
<h1><bean:message key="title.devicestatus.updateDeviceStatusForm"/></h1>
</c:otherwise>
</c:choose>
<!-- this should be an include or, better yet, use tiles and make this a footer !-->
<logic:messagesPresent>
<span id="errorsHeader"><bean:message key="errors.validation.header"/></span>
<html:messages id="error">
<li><c:out value="${error}"/></li>
</html:messages>
<hr>
</logic:messagesPresent>
<logic:messagesPresent message="true">
<html:messages id="message" message="true">
<span id="success"><c:out value="${message}"/></span><br>
</html:messages>
</logic:messagesPresent>
<html:form action="deviceStatusAction" focus="status">
<table>
<tr>
<td ><bean:message key="display.devicestatus.status"/></td>
<td><c:choose>
<c:when test="${DeviceStatusForm.map.dispatch == 'insert'}">
<html:text property="status"/>
</c:when>
<c:otherwise>
<html:text property="status"/>
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td ><bean:message key="display.devicestatus.statusName"/></td>
<td><html:text property="statusName"/></td>
</tr>
<tr>
<td ><bean:message key="display.devicestatus.deviceTypeId"/></td>
<!--td><html:text property="deviceTypeId"/></td-->
<td><html:select name="DeviceStatusForm" property="deviceTypeId">
<html:options collection="deviceInfoDict" property="id" labelProperty="name"/>
</html:select>
</td>
</tr>
</table>
<html:hidden name="DeviceStatusForm" property="dispatch"/>
<html:hidden property="recId"/>
<c:choose>
<c:when test="${DeviceStatusForm.map.dispatch == 'insert'}">
<html:submit><bean:message key="button.submit"/></html:submit>
</c:when>
<c:otherwise>
<html:submit><bean:message key="button.update"/></html:submit>
</c:otherwise>
</c:choose>
</html:form>
</center></body>
</html>
我要对status加一个验证,validation.xml文件如下:
<form name="DeviceStatusForm">
<field property="status"
depends="required,maxlength">
<arg0 key="display.deviceaction.deviceTypeId"/>
<arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>4</var-value>
</var>
</field>
</form>
struts-config.xml文件如下:
<action path="/deviceStatusAction"
type="sc.snow.devicestatus.DeviceStatusAction"
name="DeviceStatusForm"
scope="request"
validate="true"
parameter="dispatch"
input="/pages/devicestatus/deviceStatusForm.jsp"
>
<forward
name="continue"
path="/pages/devicestatus/deviceStatusResult.jsp"/>
</action>
错误信息是:
javax.servlet.ServletException: Cannot find bean under name deviceInfoDict
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.pages.devicestatus.deviceStatusForm_jsp._jspService(deviceStatusForm_jsp.java:132)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)