Reputation: 16147
I am uploading a file to my Server using Struts2 file upload, my question is that how do I specifically tell that the it is a requirement to upload a file? here is my interceptor.
<action name="audioupload" class="actions.AudioUploadAction"
method="execute">
<interceptor-ref name="basicStack" />
<interceptor-ref name="fileUpload">
<param name="allowedTypes">text/html</param>
</interceptor-ref>
<interceptor-ref name="validation" />
<interceptor-ref name="workflow" />
<result name="input">/UploadAudio.jsp</result>
<result name="success">/UploadSuccess.jsp</result>
</action>
How do I specifically tell that the user is required to upload a file?
Upvotes: 0
Views: 1445
Reputation: 4732
What you can do is create a ActionClass-validation.xml and inside that you'll declare it here.
<validators>
<field name="theNameOfTheFileTag">
<field-validator type="required">
<message>File is required.</message>
</field-validator>
</field>
</validators>
Upvotes: 3