Dear All, i am sorry, is my bad. the validation are running well. i am trying to do show the message error in action, but in this code the message going to the field with parameter named “parameterString1” and i change requiredFiled validation to requiredString validation in parameter Validations Annotation.
Thank You All > On 4 Jun 2020, at 12.00, M Huzaifah <mhuzaifah.i...@gmail.com> wrote: > > Hii Guys, > > i’am stuck with Validation in Struts2 using struts2-spring plugin. > struts version : 2.5.22 > spring version : 5.2.1.RELEASE > > my validators.xml in classpath: > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE validators PUBLIC > "-//Apache Struts//XWork Validator Definition 1.0//EN" > "http://struts.apache.org/dtds/xwork-validator-definition-1.0.dtd > <http://struts.apache.org/dtds/xwork-validator-definition-1.0.dtd>"> > <validators> > <validator name="required" > class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/> > <validator name="requiredstring" > class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/> > <validator name="conversion" > class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/> > </validators> > > > my struts.xml config form constant Struts-spring: > > > <constant name="struts.devMode" value="true"/> > <constant name="struts.objectFactory" value="spring" /> > <constant name="struts.objectFactory.spring.autoWire" value="name" /> > > > my validation method using Annotation > > > //validation > @Validations( requiredFields = { > @RequiredFieldValidator(type = ValidatorType.SIMPLE, > fieldName = "parameterString1", message = "You must enter a value for field.") > } > ) > @Action(value = "testingValidation", results = { > @Result(name = "success", location = > "/pages/blank.jsp"), > @Result(name = "input", location = "/pages/blank.jsp"), > @Result(name = "error", location = "/pages/blank.jsp") > }, > interceptorRefs = { > @InterceptorRef("validation") > }) > public String testingValidation() { > List<String> a = new ArrayList<String>(); > a.add("salah field"); > setActionMessages(a); > return SUCCESS; > } > > when i hit the URL http://localhost:8080/baseapp/example/testingValidation > <http://localhost:8080/baseapp/example/testingValidation>(without parameter) > it does’t show my error message, the error should shown using > <s:actionerror/> tag in JSP. > > when i trace the log, here i found: > > > [http-nio-8080-exec-6] DEBUG > com.opensymphony.xwork2.validator.ValidationInterceptor - Validating > /example/testingValidation with method testingValidation. > [http-nio-8080-exec-6] TRACE > org.springframework.beans.factory.support.DefaultListableBeanFactory - Not > autowiring property 'textProviderFactory' of bean > 'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by > name: no matching bean found > [http-nio-8080-exec-6] TRACE > org.springframework.beans.factory.support.DefaultListableBeanFactory - Not > autowiring property 'validatorContext' of bean > 'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by > name: no matching bean found > [http-nio-8080-exec-6] TRACE > org.springframework.beans.factory.support.DefaultListableBeanFactory - Not > autowiring property 'valueStack' of bean > 'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by > name: no matching bean found > > the spring nt autowiring validation. > > > > > > >