0
저는 XML을 사용하여 Struts2 유효성 검사를 사용하여 고객이 입력 한 다양한 필드를 검사하려고합니다. 내 struts.xml
은 struts-default
으로 확장되며 매우 간단한 동작 클래스 TestAction
은 ActionSupport
으로 확장되었지만 작동하지 않습니다.Struts2 XML을 사용하는 유효성 검사가 작동하지 않습니까?
내가 부족한 것을 누군가도 볼 수 있다면 매우 감사하게 생각합니다. 여기
내가 가진 무엇 :CustomerAction-validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
<validators>
<field name="customerName">
<field-validator type="requiredstring">
<message>Required</message>
</field-validator>
</field>
</validators>
struts.xml 여기
<action name="addCustomer" class="com.yell.hibu.action.CustomerAction"
method="execute">
<interceptor-ref name="validation"/>
<param name="excludeMethods">
input,back,cancel,browse
</param>
<interceptor-ref name="fileUpload">
<param name="maximumSize">2097152</param>
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/pjpeg
</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/success.jsp</result>
<result name="input">/registration.jsp</result>
</action>
난 단지 1 개 필드
에 대한 Registration.jsp이<s:form action="addCustomer" id="register-form" method="post" validate="true" theme="xhtml" enctype="multipart/form-data">
<s:actionerror/>
<s:fielderror/>
<s:textfield name="customer.customerName" label="Customer Name:" cssClass="tooltip" title="Max 10 characters allowed." maxlength="10"/>
도움이 될 정보가 충분하지 않습니다. 유효성 검사 파일은 어디에 배포됩니까? 무슨 일이 생기지 않습니까? 작업에 적절한 getter/setter가 있습니까? –
'TestAction' 클래스의 코드는 무엇입니까? –
이 링크를 사용해보세요. 문제가 해결되기를 바랍니다. http://www.roseindia.net/struts/struts/struts2.2.1/ValidationInterceptor.html –